HOW TO FIND A TEXT IN A DRAWING USING MACRO. I FOUND THE EXAMPLE IN API BUT IT IS NOT WORKING
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim longstatus As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
' Find and replace annotations
Set swUtil = swApp.GetAddInObject("Utilities.UtilitiesApp")
Set swUtilFindReplaceAnnotations = swUtil.FindReplaceAnnotations
longstatus = swUtilFindReplaceAnnotations.InitPMPage()
swUtilFindReplaceAnnotations.FindText = "abc"
swUtilFindReplaceAnnotations.ReplaceText = "def"
swUtilFindReplaceAnnotations.options = gtFraWholeWord
swUtilFindReplaceAnnotations.AnnotationFilter = gtFraNote
longstatus = swUtilFindReplaceAnnotations.FindNext()
longstatus = swUtilFindReplaceAnnotations.Replace()
longstatus = swUtilFindReplaceAnnotations.Close()
End Sub
COULD SOMEONE HELP ME IN THIS REGARD BY MODIFYING THE ATTACHED MACRO.
SolidworksApi macros
deepak,
thanks for the macro.
this macro works well if i select the text in the drawing and run the macro.
But i am looking for a macro that will search a test and replace it with new text.
Thanks once again for taking time on this.
Thanks deepak,
It worked for my macro.
Actually you are doing a Find and replace and SolidWorks Utilities are required for that.
I want the macro when there is no annoation (text) in the drawing. how to do that .
for example if a drawing has annotation text saying "ALL DIMENSIONS ARE IN MM" then my macro should not run.
else if the drawing doesn't have annotation text saying "ALL DIMENSIONS ARE IN MM" then the macro has to work.
TRY
Thanks deepak,
I am not good in macro could you please create a macro and send to me.
Thanks,