Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle dimension between driven and driving

API and Macros

Toggle dimension between driven and driving

by  linqur  Posted    (Edited  )
' This Macro Checks the current selected group for dimensions, determines if they
' are driven or driving dimensions, and toggles them from one to the other.
Dim swApp As Object
Dim Part As Object
Dim i As Integer
Dim ObjType, objCount As Variant
Dim SelMgr, SelDim As Object

Sub main()

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager()
'Make sure there are selected objects
If SelMgr.GetSelectedObjectCount <> 0 Then
objCount = SelMgr.GetSelectedObjectCount
For i = 1 To objCount
ObjType = SelMgr.GetSelectedObjectType(i)
If (ObjType = 14) Then 'If the object is a dimension...
Set SelDim = SelMgr.GetSelectedObject(i)
If SelDim.DrivenState = 2 Then 'if driving dim then
SelDim.DrivenState = 1 ' set to driven
Else
SelDim.DrivenState = 2 ' set to driving
End If
End If
Part.GraphicsRedraw2
Next i
End If
End

End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search