AnsweredAssumed Answered

Dimension from Driving to Driven in 3D Sketch

Question asked by Will Benson on Jun 30, 2013
Latest reply on Sep 17, 2014 by Scott Rypstra

I am looking to change a 3D drawing dimension from driven to driving and vise versa.

This code works perfect for 2D, but not at all for 3D. Any thoughts?

' 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


            SelDim.DrivenState = 2 ' set to driving

        End If

    End If


Next i

End If


End Sub