1 Reply Latest reply on Jun 11, 2014 11:37 AM by Simon Turner

    Fix endpoints of a line using createline2

    Ryan Gerry

      I am writing a macro that creates a line in a  SW Part from selected start and end points in excel.  I am trying to create these lines and have them fully defined, however when I use the following code:


      Part.CreateLine2 sX, sY, sZ, eX, eY, eZ

      Part.SketchAddConstraints "sgFIXED"


      It draws the line and defines the line orientation only, leaving the endpoints free to be moved. 


      How do I get the endpoints and fix them also?

        • Re: Fix endpoints of a line using createline2
          Simon Turner

          Part.CreateLine2 leaves the line segment selected.

          You need to select one of the endpoints before calling SketchAddConstraints


          Something like:


          Dim mySeg as SketchSegment

          Dim myLine as SketchLine

          Dim myPt as SketchPoint


          Set mySeg = Part.SketchManager.CreateLine(sX, sY, sZ, eX, eY, eZ)

          Set myLine = mySeg

          Set myPt = myLine.GetStartPoint2

          myPt.Select4 False, Nothing

          Part.SketchAddConstraints "sgFIXED"


          Set myPt = myLine.GetEndPoint2

          myPt.Select4 False, Nothing

          Part.SketchAddConstraints "sgFIXED"