1 Reply Latest reply on Dec 22, 2015 7:00 PM by Yong Ning

    How get feature name in create circle.

    Yong Ning

      0.jpg

      follow code.

               SwSktSeg.Select2 True, 0 →  can be select

       

               Set SwFeat = SwSelMgr.GetSelectedObject5(1) → don't set SwFeat

       

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

      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 SwSktSeg  As SketchSegment, SwFeat As Feature, SwSketch As Sketch

            With SwModel

               'tmp = .Extension.SelectByID2("上视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

               tmp = .Extension.SelectByID2("上视", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

               Set SwSktSeg = .CreateCircleByRadius2(0, 0, 0, 24)       

               SwSktSeg.Select True

               SwSktSeg.GetSketch       

               .InsertSketch2 True

               Set SwSketch = SwSktSeg.GetSketch

             

               SwSktSeg.Select2 True, 0

               Stop

               Set SwFeat = SwSelMgr.GetSelectedObject5(1)

            End With

      End Sub

        • Re: How get feature name in create circle.
          Yong Ning

          1.jpg

           

          Traverse select Feature of Sketch name, change Feature name.

           

          Private Sub ll3()

             Dim Xls As Excel.Application, Rng As Range

                Set Xls = GetObject(, "Excel.Application")

                Set Rng = Xls.Selection

             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 SwSktSeg  As SketchSegment, SwFeat As Feature, SwSketch As Sketch

                With SwModel

                   For ii = 1 To Rng.Rows.Count

                       tmp = .Extension.SelectByID2("Sketch" & ii, "SKETCH", 0, 0, 0, False, 0, Nothing, 0)

                       Set SwFeat = SwSelMgr.GetSelectedObject5(1)

                       Debug.Print SwFeat.Name

                       SwFeat.Name = Rng(ii, 1)

                   Next ii

                End With

           

          End Sub

           

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

           

           

          How to get the feature name of Cut-Extrude? | SOLIDWORKS Forums

          https://forum.solidworks.com/message/466157#466157

           

           

           

           

          Private Sub ll()

            Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

               Set SwApp = Application.SldWorks

               Set SwModel = SwApp.ActiveDoc

            Dim SwSelMgr As SelectionMgr, Tmp

               Set SwSelMgr = SwModel.SelectionManager

            Dim SwFeat As Feature

            Dim SwAnn As Annotation, S As Sketch

               With SwModel

                  Tmp = .Extension.SelectByID2("上视", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

                  .CreateCircleByRadius2 0, 0, 0, 38.5 / 2 / 1000

                  .ClearSelection2 True

                  Set SwFeat = .GetActiveSketch

                  'SwFeat.Select True

                  SwFeat.Name = "f1"

                  SwFeat.Select True

                  Stop

                  Set SwFeat = .FeatureManager.FeatureCut(True, False, True, swEndCondThroughAll, _

                    swEndCondBlind, 0, 0, False, False, False, False, 0, 0, False, False, False, False, 0, 1, 1)

                  Stop

                  SwFeat.Name = "fffffff"

                  SwFeat.Select True

                  SwModel.EditSuppress

            

               End With

          End Sub

          ''