I am trying to add/edit global variables in Solidworks 2021 with a macro. When I use the Application.SldWorks.ActiveDoc.GetEquationMgr.Add2(0, “”“A”" = 2in", True) function this is possible, but for some reason I can’t get the get Add3 and SetEquationAndConfigurationOption to work. This is the code I’m using:
Dim SwApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2Dim swEquationMgr As SldWorks.EquationMgr
Dim longEquation As LongSub main()
Set SwApp = Application.SldWorks
Set swModel = SwApp.ActiveDoc
Set swEquationMgr = swModel.GetEquationMgr
longEquation = swEquationMgr.Add2(0, “”“A”" = 2in", True)
If longEquation <> 0 Then Debug.Print “Failed to add2 a global variable assignment”’ ^ Works
longEquation = swEquationMgr.Add3(1, “”“B”" = 2in", True, swAllConfiguration, Empty)
If longEquation <> 0 Then Debug.Print “Failed to add3 a global variable assignment”’ ^ Doesn’t work
longEquation = swEquationMgr.SetEquationAndConfigurationOption(0, “”“A”" = 3in", swAllConfiguration, Empty)
If longEquation <> 0 Then Debug.Print “Failed to change a global variable assignment”’ ^ Doesn’t work
End Sub