5 Replies Latest reply on Nov 27, 2017 4:19 AM by Robert H.

    how do i call up the last two lines created in a drawing ?

    Robert H.

      i am trying to make a macro to streamline some common / basic sketches that are used on a regular basis

       

      Thank you

        • Re: how do i call up the last two lines created in a drawing ?
          Solid Air

          Please supply screen shots of what you are trying to accomplish.   I cannot decide if you are asking to draw lines, copy lines or ?

          • Re: how do i call up the last two lines created in a drawing ?
            Dave Bear

            Hi Robert,

            I have to agree with Solid Air's comment at this stage because your thread title doesn't even seem to match your secondary comment. What is it exactly that you need help with?

             

            Dave.

              • Re: how do i call up the last two lines created in a drawing ?
                Robert H.

                basically trying to set up a marco button to draw some shapes i have to draw on a regular basic

                 

                so the problem i have is that line 18 and line 17 will not be line 19 and 17 but the last two lines created so i need to call back to the last two lines created  so i can make the lines the same SAMELENGTH every time.

                 

                 

                 

                 

                Dim swApp As Object

                 

                 

                Dim Part As Object

                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.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstToRectEntity, swUserPreferenceOption_e.swDetailingNoOptionSpecified, False)

                boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstLineDiagonalType, swUserPreferenceOption_e.swDetailingNoOptionSpecified, True)

                Dim vSkLines As Variant

                vSkLines = Part.SketchManager.CreateCornerRectangle(-2.40287249627679E-02, -6.2096704959962E-03, 0, 3.64480659547603E-02, 1.86290114879886E-02, 0)

                Part.ClearSelection2 True

                Dim skSegment As Object

                Set skSegment = Part.SketchManager.CreateCenterLine(-0.024029, 0.00621, 0#, -0.054267, 0.00621, 0#)

                Part.SetPickMode

                Part.ClearSelection2 True

                Set skSegment = Part.SketchManager.CreateCenterLine(0.036448, 0.00621, 0#, 0.078296, 0.00621, 0#)

                Part.SetPickMode

                Part.ClearSelection2 True

                boolstatus = Part.Extension.SelectByID2("Line18", "SKETCHSEGMENT", 0.061826719286223, 0, -6.47965616973517E-03, False, 0, Nothing, 0)

                boolstatus = Part.Extension.SelectByID2("Line17", "SKETCHSEGMENT", -4.18477794295397E-02, 0, -5.66969914851828E-03, True, 0, Nothing, 1)

                Part.SketchAddConstraints "sgSAMELENGTH"

                Part.ClearSelection2 True

                End Sub