4 Replies Latest reply on Apr 9, 2018 9:42 AM by Jacob Corder

    How to change start or end point of line?

    Yong Ning

      00.jpg

      Follow can get Start or End Point of line.

       

       

      Help me , Move Point

       

      ''

      Private Sub del()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

            Set SwApp = Application.SldWorks

            Set SwModel = SwApp.ActiveDoc

         Dim SwDraw As DrawingDoc, vSketchSeg

         Dim ii, sArr, eArr

            Set SwDraw = SwModel

         Dim SwSketchSeg As SketchSegment, SwLine As SketchLine

            vSketchSeg = SwModel.GetActiveSketch2.GetSketchSegments

            For ii = 0 To UBound(vSketchSeg)

               Set SwLine = vSketchSeg(ii)

               With SwLine

                  sArr = .GetStartPoint

                  eArr = .GetEndPoint    

               End With

               Stop     

            Next ii

      End Sub

       

      ***********************************************

      SketchLine Object.The SketchLine object is derived from SketchSegment.

      have getEndPoint Sentance, no setEndPoint Sentance.

      01.jpg

        • Re: How to change start or end point of line?
          Yong Ning

          Now can delete line, follow code is

           

          Function delLine(SwModel)

             Dim SwSketchSeg As SketchSegment, vSketchSeg, ii

                vSketchSeg = SwModel.GetActiveSketch2.GetSketchSegments

                For ii = 0 To UBound(vSketchSeg)

                   Set SwSketchSeg = vSketchSeg(ii)

                   SwSketchSeg.Select2 True, ii

                Next ii

                SwModel.EditDelete

          End Function

           

          rebuild draw line

           

          Function LabTitLine(SwDraw As DrawingDoc, XyLabTit As LabTitle, _

                  SheetRng As Range, TitleRng As Range)

             ''表格处理

             Dim X1, Y1, X2, Y2, X3, Y3, X4, Y4

             Kk1 = SheetRng.Rows.Count + 1

             Dim oScale, SwSheet As Sheet, ss

               For ii = 1 To SheetRng.Rows.Count

                  SwDraw.ActivateSheet SheetRng(ii, 1)

                  SwDraw.ViewZoomtofit

                  Set SwSheet = SwDraw.GetCurrentSheet     

                  ss = SwSheet.GetProperties

                  oScale = ss(3) / 1000

                  With XyLabTit

                     X1 = .titX:    Y1 = .titY

                     X2 = .labX + 5: Y2 = .titY

                     SwDraw.CreateLine2 X1 * oScale, Y1 * oScale, 0, X2 * oScale, Y2 * oScale, 0

                     ''

                     X3 = X2:        

                  

                     Y3 = .yLabArr(Kk1) - (.yLabArr(Kk1) - .yLabArr(Kk1 - 1)) / 2

                     SwDraw.CreateLine2 X2 * oScale, Y2 * oScale, 0, X3 * oScale, Y3 * oScale, 0

                     ''

                     X4 = .labX

                     Y4 = Y3

                     SwDraw.CreateLine2 X3 * oScale, Y3 * oScale, 0, X4 * oScale, Y4 * oScale, 0

                     Kk1 = Kk1 - 1

                  End With

               Next ii

          End Function

          ***********************************************************

          Private Sub ll()

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

              Dim SwSelMgr As SelectionMgr

                  Set SwSelMgr = SwModel.SelectionManager

              Dim SwDraw As DrawingDoc

                  Set SwDraw = SwModel

              Dim SwView As View

                  Set SwView = SwSelMgr.GetSelectedObject5(1)

              Dim vLines, lCount

                  vLines = SwView.GetLines4(1)

                  lCount = SwView.GetLineCount2(1)

                 

                  For i = 0 To SwView.GetLineCount - 1

                       Debug.Print "    line[" & i & "]"

                          Debug.Print "      start pt = (" & vLines(i * 12 + 6) * 1000# & ", " & vLines(i * 12 + 7) * 1000# & ", " & vLines(i * 12 + 8) * 1000# & ") mm"

                          Debug.Print "      end   pt = (" & vLines(i * 12 + 9) * 1000# & ", " & vLines(i * 12 + 10) * 1000# & ", " & vLines(i * 12 + 11) * 1000# & ") mm"

                  Next i

                  SwModel.ClearSelection

              Dim SwSketch As Sketch, vSketchSeg, SwSketchSeg As SketchSegment

                  Set SwSketch = SwView.GetSketch

                 

                  vSketchSeg = SwSketch.GetSketchSegments

                For ii = 0 To UBound(vSketchSeg)

                   Set SwSketchSeg = vSketchSeg(ii)

                   SwSketchSeg.Select2 True, ii

                Next ii

                ''

                SwModel.EditDelete

          End Sub

          • Re: How to change start or end point of line?
            Solid Air

            Look at ISketchPoint Interface Members.  This may be what you are looking for (I have never tried it myself).