AnsweredAssumed Answered


Question asked by Yong Ning on Feb 4, 2016
Latest reply on Feb 5, 2016 by Yong Ning

Private Sub AddEquation()

   Dim Xls As Excel.Application, Rng As Range

      Set Xls = GetObject(, "Excel.Application")

      Set Rng = Xls.Selection

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

      Set SwApp = Application.SldWorks

      Set SwModel = SwApp.ActiveDoc

   Dim SwEqnMgr As EquationMgr, Arr()

      Set SwEqnMgr = SwModel.GetEquationMgr

      Debug.Print SwEqnMgr.GetCount


      With SwEqnMgr

          ReDim Arr(.GetCount)

          For ii = .GetCount To 0 Step -1

              Arr(ii) = .Equation(ii)

              Debug.Print .Equation(ii), .Value(ii), .Suppression(ii)

              .Delete ii

          Next ii

          SwModel.ForceRebuild3 True


          For ii = 1 To Rng.Rows.Count

             .Add ii - 1, Rng(ii, 1)

          Next ii

      End With

      SwModel.ForceRebuild3 True



End Sub