Hi,
Has anyone experienced issues adding Global Variables or Equations to an assembly document using the API (VBA). I have tested many variations of the below code without success.
I am trying to a Global Variable named "Toggle" which will have a value of 1.
Any help would be greatly appreciated.
Dim swApp As Object
Dim swModel As SldWorks.ModelDoc2
Dim swEqnMgr As SldWorks.EquationMgr
Dim longEq As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swEqnMgr = swModel.GetEquationMgr()
Debug.Print "Adding..."
longEq = swEqnMgr.Add2(-1, """TOGGLE"" = 1", True)
If Not longEq = -1 Then
MsgBox ("Success")
End If
Debug.Print "Number of equations in EquationMgr is " & swEqnMgr.GetCount
swModel.ForceRebuild3 (True)
End Sub
*UPDATE: I have tested this code on other parts/ assemblies and it seems to work as expected. Is there anything that would prevent it working on a specific assembly?
