3 Replies Latest reply on Aug 29, 2014 1:54 AM by Yong Ning

    traverse Sketch → How to get "Arc1@Sketch" ?

    Yong Ning

      macro recorded → result.

      boolstatus = Part.Extension.SelectByID2("Arc1@Sketch", "EXTSKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)

       

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

      Traverse Sketch → gettype

      Private Sub ll1()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

          Set SwApp = Application.SldWorks

          Set SwModel = SwApp.ActiveDoc

        Dim SwSelMgr As SelectionMgr, SwFeat As Feature

          Set SwSelMgr = SwModel.SelectionManager

          Set SwFeat = SwSelMgr.GetSelectedObject5(1)

        Dim SwSketch As Sketch, SkSegArr, SkSeg As SketchSegment

          Set SwSketch = SwFeat.GetSpecificFeature

          SkSegArr = SwSketch.GetSketchSegments

          For ii = 0 To UBound(SkSegArr)

            Set SkSeg = SkSegArr(ii)

            Debug.Print SkSeg.GetType, Round(SkSeg.GetLength, 6)

            SkSeg.Select2 True, 1

          Next

      End Sub

       

      Help me

      Traversing sketch → How to get "Arc1@Sketch" style.

        • Re: traverse Sketch → How to get "Arc1@Sketch" ?
          Yong Ning

          Have  "Line1@Sketch1"→ SelectByID2 "Line1@Sketch1" → SketchSegment

          Help me

          How to get "Line1@Sketch1" From SketchSegment

           

           

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

          Private Sub llll()

            Dim swModel As ModelDoc2, swSelMgr As SelectionMgr

              Set swModel = Application.SldWorks.ActiveDoc

              Set swSelMgr = swModel.SelectionManager

           

            Dim SwSeg As SketchSegment, SegLine As SketchLine, Ss 'As Variant

              swModel.Extension.SelectByID2 "Line1@Sketch1", "EXTSKETCHSEGMENT", 0, 0, 0, False, 1, Nothing, 0

              Debug.Print "SelType      = " & swSelMgr.GetSelectedObjectType2(1)

              Set SwSeg = swSelMgr.GetSelectedObject2(1)

                                            ' →  How to get the  "Line1@Sketch1"

              Debug.Print SwSeg.GetLength

          End Sub

            • Re: traverse Sketch → How to get "Arc1@Sketch" ?
              Ivana Kolin

              Dim vId  As Variant

                  vId = SwSeg.GetID

                  Dim swsk As SldWorks.Sketch

                  Set swsk = SwSeg.GetSketch

                  Select Case SwSeg.GetType

                      Case swSketchARC

                      Debug.Print "Arc" & vId(1) & "@" & swsk.Name

                      Case swSketchELLIPSE

                      Debug.Print "Ellipse" & vId(1) & "@" & swsk.Name

                      Case swSketchLINE

                      Debug.Print "Line" & vId(1) & "@" & swsk.Name

                      Case swSketchPARABOLA

                      Debug.Print "Parabola" & vId(1) & "@" & swsk.Name

                      Case swSketchSPLINE

                      Debug.Print "Spline" & vId(1) & "@" & swsk.Name

                      Case swSketchTEXT

                      Debug.Print "Text" & vId(1) & "@" & swsk.Name

                  End Select

                • Re: traverse Sketch → How to get "Arc1@Sketch" ?
                  Yong Ning

                  Thanks your key code → GetID(1)

                   

                   

                  Private Sub ll1()

                    Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                      Set SwApp = Application.SldWorks

                      Set SwModel = SwApp.ActiveDoc

                    Dim SwSelMgr As SelectionMgr, SwFeat As Feature, gID

                      Set SwSelMgr = SwModel.SelectionManager

                      Set SwFeat = SwSelMgr.GetSelectedObject5(1)

                    Dim SwSketch As Sketch, SkSegArr, SkSeg As SketchSegment

                      Set SwSketch = SwFeat.GetSpecificFeature

                      SkSegArr = SwSketch.GetSketchSegments

                      For ii = 0 To UBound(SkSegArr)

                        Set SkSeg = SkSegArr(ii)

                        gID = SkSeg.GetID(1)

                        ''

                        Select Case SkSeg.GetType

                            Case swSketchARC

                               Debug.Print "Arc" & gID & "@" & SwSketch.Name

                            Case swSketchELLIPSE

                               Debug.Print "Ellipse" & gID & "@" & SwSketch.Name

                            Case swSketchLINE

                               Debug.Print "Line" & gID & "@" & SwSketch.Name

                            Case swSketchPARABOLA

                               Debug.Print "Parabola" & gID & "@" & SwSketch.Name

                            Case swSketchSPLINE

                               Debug.Print "Spline" & gID & "@" & SwSketch.Name

                            Case swSketchTEXT

                               Debug.Print "Text" & gID & "@" & SwSketch.Name

                        End Select

                        ''

                        SkSeg.Select2 True, 1

                      Next

                  End Sub