1 Reply Latest reply on Jan 26, 2013 7:08 PM by Artem Taturevych

    How to obtain sketh name?

    Yong Ning

      0.jpg

       

      Set oSketch = .GetActiveSketch2

      but don't obtain Sketch name?

       

      the code is

       


      Sub ll1()
        Dim SwApp As SldWorks.SldWorks
        Dim SwModel As ModelDoc2
        Dim oFeat As Feature
        Set SwApp = Application.SldWorks
        Set SwModel = SwApp.ActiveDoc
        Dim oSketch As Sketch

        Dim SwSelMgr As SelectionMgr
        Dim vPtArr, SwSkethPoint As SketchPoint
       
       
        With SwModel
          Set SwSelMgr = .SelectionManager
          Set oSketch = .GetActiveSketch2

          vPtArr = oSketch.GetSketchPoints
               For Each Pt In vPtArr
                 Set SwSkethPoint = Pt
                 With SwSkethPoint
                    Debug.Print .Type
                   .Select4 False, Nothing
                 End With
               Next
        End With
      End Sub

      *****

      http://help.solidworks.com/2010/English/api/sldworksapi/Get_Hole_Series_Information_Example_VB.htm

        • Re: How to obtain sketh name?
          Artem Taturevych

          Check lines in red:

            Dim SwApp As SldWorks.SldWorks

            Dim SwModel As ModelDoc2

            Dim oFeat As Feature

            Set SwApp = Application.SldWorks

            Set SwModel = SwApp.ActiveDoc

            Dim oSketch As Sketch

            Dim SwSelMgr As SelectionMgr

            Dim vPtArr, SwSkethPoint As SketchPoint

           

           

            With SwModel

              Set SwSelMgr = .SelectionManager

              Set oSketch = .GetActiveSketch2

              Set oFeat = oSketch

              Dim sketchName As String

              sketchName = oFeat.Name

              Debug.Print sketchName

              vPtArr = oSketch.GetSketchPoints

                   For Each Pt In vPtArr

                     Set SwSkethPoint = Pt

                     With SwSkethPoint

                        Debug.Print .Type

                       .Select4 False, Nothing

                     End With

                   Next

            End With

          __________________________

          Regards,

          Artem Taturevych

          Application Engineer at Intercad

          http://intercad.com.au/

          Tel: +61 2 9454 4444