4 Replies Latest reply on Feb 8, 2018 1:59 PM by Michael Capitain

    Changing a global variable with a macro

    Martin M.

      I have a global variable named "length" that changes the length of a line in my model. I am trying to write a macro to change the value of length, however my macro only seems to work when I set a number equal to length (such as: swEqnMgr.Equation(1) = """length""= 7"). I can't get my macro to work with a variable as shown below. I'd like to get it to work with a variable so that I can iterate the value of length.

       

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swEqnMgr As SldWorks.EquationMgr

      Dim newLength As Variant

       

      Sub main()

       

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swEqnMgr = swModel.GetEquationMgr

          newLength = 9   

          swEqnMgr.Equation(1) = """length""= newLength"

              

      End Sub