1 Reply Latest reply on Aug 25, 2016 7:56 AM by Lennart Floreby

    Save Problems after accessing a part's Equation Manager

    Thomas Alleman



      I am having an issue with my parts not saving in the assembly after I run my macro.


      I get an error that says "an unknown error occurred while accessing <...filepath>"


      If I explicitly go into the part file, and open the equation manager and close it, it allows me to save the file again.


      Thanks for any help on this.


      Here is the code that I am having problems with


      Dim swApp As SldWorks.SldWorks
      Dim swModel As SldWorks.ModelDoc2
      Dim swAssy As SldWorks.AssemblyDoc
      Dim swConf As SldWorks.Configuration
      Dim RootComp As SldWorks.Component2
      Dim swEquationMgr As SldWorks.EquationMgr
      Dim bRet As Boolean


      Sub main()
      Set swApp = Application.SldWorks
      Set swModel = swApp.ActiveDoc
      Set swEquationMgr = swModel.GetEquationMgr

      swModel.GetComponentByName("MACTEST-1").GetModelDoc2.GetEquationMgr.Equation(1) = """Length""" & "=90"
      swModel.ForceRebuild3 (False)

      End Sub

        • Re: Save Problems after accessing a part's Equation Manager
          Lennart Floreby

          I don’t really have a clear answer to this, but I will share what I have.


          Using your example, this is when I get the “unknown error” problem:


          For me “MACTEST-1” would be a subassembly to which there has been applied an assembly-extruded-cut from a different subassembly (outside MACTEST-1), and MACTEST-1 would include parts that were suppressed before updating the equation, but unsuppressed after updating the equation (or perhaps the other way around), through feature-suppress-equations that changed between “suppressed” and “unsuppressed” when, using your example, Length was assigned to 90.


          I guess, that the point is the combination of MACTEST-1 having feature-suppressions that change, MACTEST-1 is dependent on things external to itself, and MACTEST-1 not being open when its equation is updated. This combination cannot be handled by the system. If I remove the assembly-extruded-cut feature, the problem goes away.


          This problem is irrelevant when manipulating through the user interface, since the equation manager cannot be opened if its component isn’t opened or chosen for edit first.


          Note that in the code swEquationMgr is not the equation manager used in the equation assignment.


          Also note that the documentation uses calls to SetEquationAndConfigurationOption instead of updating the equation with a simple assign statement. Perhaps we should consider direct assignment of equations to be obsoleted by this new variant. However, for me it didn’t help to use that call instead.


          I use SW 2014 SP 5.0.