MACRO LIBRARY

Change the dimension colors in selected view

Free public access. No account or subscription required.

Files

Change the dimension colors in selected view

Code

'Changes the color all display dimensions in a selected drawing view
    
'Preconditions: drawing is open and view is selected
'Result: display dimension colors are changed
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim swDim As SldWorks.Dimension
Dim vDims As Variant
Dim i As Integer
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swSelMgr = swModel.SelectionManager
    Set swView = swSelMgr.GetSelectedObject6(1, -1)
    vDims = swView.GetDimensionIds4
    swModel.ClearSelection2 True
    For i = 0 To UBound(vDims)
        swModel.Extension.SelectByID2 vDims(i), "DIMENSION", 0, 0, 0, True, 0, Nothing, 0
    Next i
    swDraw.SetLineColor RGB(255, 0, 0)  'the color red
End Sub