3 Replies Latest reply on Feb 2, 2015 9:33 AM by Jacob Ely

    SolidWorks API - EditReferencePoint

    Jacob Ely

      I'm trying to automate a process with SolidWorks API.

      I have a 3D spline. I'm trying to insert reference planes evenly along the spline. In order to do so, I've created reference points evenly along the spline and then use the reference point to create planes. The problem is, when I modify the spline, the reference points show up with a distance relationship along the spline instead of evenly spaced.

      I'm going to be using a macro anyway, so I have no problem having a macro measure the spline and then adjust the reference points accordingly each time I edit the spline.

      I'm attempting to do this using the function "EditReferencePoint". I have searched but found almost no info about this function, only what is in the API help itself (no examples).

      Can anyone help me get this to work?

      Here is the code, simply trying to get EditReferencePoint to work.

      I've tried selecting both the reference point and the spline and just the reference point and nothing seems to work.

      If I step through the code, the boolstatus is always "False" when it executes that line.

       

      Option Explicit

      Dim Part As Object
      Dim swApp As SldWorks.SldWorks
      Dim boolstatus As Boolean
      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

      Set swApp = Application.SldWorks
      Set Part = swApp.ActiveDoc

      Part.ClearSelection2 True
      boolstatus = Part.Extension.SelectByID2("Spline1@CentCurve", "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Point59", "DATUMPOINT", 0, 0, 0, True, 0, Nothing, 0)
      boolstatus = Part.FeatureManager.EditReferencePoint(2, 0, 0.002, 1)
      boolstatus = Part.EditRebuild3()
      Part.ClearSelection2 True

      End Sub

       

       

      Thanks,

        • Re: SolidWorks API - EditReferencePoint
          Jacob Ely

          I'll ask the question another way... Is there any way to modify a reference point in API?

          I've tried recording a macro to discover the API calls, but the macro only records the selection of the points I'm modifying and not the function that modifies it.

          Would someone mind placing a reference point on a curve and trying to use EditReferencePoint (or other method) to modify the distance along the curve?

            • Re: SolidWorks API - EditReferencePoint
              Ivana Kolin
              Option Explicit
              Dim swApp As SldWorks.SldWorks
              
              
              Dim swModel As SldWorks.ModelDoc2
              Dim boolstatus As Boolean
              
              
              Sub main()
              Dim swSelMgr As SldWorks.SelectionMgr
              Dim swFeature As SldWorks.Feature
              Dim swRefPtData As SldWorks.RefPointFeatureData
              Dim i As Integer
              Set swApp = Application.SldWorks
              
              
              Set swModel = swApp.ActiveDoc
              For i = 1 To 10
                  boolstatus = swModel.Extension.SelectByID2("Point" & i, "DATUMPOINT", 0, 0, 0, False, 0, Nothing, 0)
                  Set swSelMgr = swModel.SelectionManager
                  Set swFeature = swSelMgr.GetSelectedObject6(1, -1)
                  Set swRefPtData = swFeature.GetDefinition
                  boolstatus = swRefPtData.AccessSelections(swModel, Nothing)
                  swRefPtData.Distance = 0.05 * (i - 1)
                  swFeature.ModifyDefinition swRefPtData, swModel, Nothing
              
              Next i
              
              
              swModel.EditRebuild3
              End Sub