ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
RPRod Paslowski18/03/2015

Option Explicit

Dim swApp                       As SldWorks.SldWorks

Dim swModel                     As SldWorks.ModelDoc2

Dim swDraw                      As SldWorks.DrawingDoc

Dim swView                      As SldWorks.View

Dim swCenterLine                As SldWorks.CenterLine

Dim swcentermark                As SldWorks.CenterMark

Dim swAnn                       As SldWorks.Annotation

Dim ColorInt                    As Integer

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

ColorInt = 255

'check to see in a drawing is open

If swModel.GetType = swDocDRAWING Then

    'a drawing is open

    Set swDraw = swModel

    Set swView = swDraw.GetFirstView

    'Debug.Print "File = " & swModel.GetPathName

       

    'sort through all the views on this sheet

    Do While Not swView Is Nothing

   

        'Debug.Print "  View = " + swView.GetName2

       

        'find the center lines in this view and change their color

        Set swCenterLine = swView.GetFirstCenterLine

        Do While Not swCenterLine Is Nothing

            Set swAnn = swCenterLine.GetAnnotation

            'Debug.Print "    Name       = " & swAnn.GetName

            'swModel.DeleteEntityName swAnn.GetName

            'LCOLOR = swAnn.Color

            swAnn.Color = ColorInt

                       

            Set swCenterLine = swCenterLine.GetNext

        Loop

       

        'find the center marks in this view and change their color

        Set swcentermark = swView.GetFirstCenterMark

        Do While Not swcentermark Is Nothing

            Set swAnn = swcentermark.GetAnnotation

            'Debug.Print "    Name       = " & swAnn.GetName

            'swModel.DeleteEntityName swAnn.GetName

            'LCOLOR = swAnn.Color

            swAnn.Color = ColorInt

                       

            Set swcentermark = swcentermark.GetNext

        Loop

   

        Set swView = swView.GetNextView

    Loop

Else

    'a drawing is not open

    MsgBox "This macro requires a drawing to be the active document", vbOKOnly, "ANNOTATIAN COLOR CHANGE"

End If

End Sub