1 Reply Latest reply on Apr 1, 2016 6:40 AM by Kevin Chisholm

    How to select Mate feature  in feature tree with traverse method.

    Yong Ning

      Follow code,  traverse feature tree , how to  select   mate feature →Distance1(a<1>,a<2>)



      boolstatus = Part.Extension.SelectByID2("Distance1", "MATE", 0, 0, 0, False, 0, Nothing, 0)





      Private Sub mMate()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

             Set SwApp = Application.SldWorks

             Set SwModel = SwApp.ActiveDoc

         Dim SwFeat As Feature, SwSubFeat As Feature

             Set SwFeat = SwModel.FirstFeature

             Do While Not SwFeat Is Nothing

                'Debug.Print SwFeat.Name, SwFeat.GetTypeName

                Set SwSubFeat = SwFeat.GetFirstSubFeature


                If SwFeat.GetTypeName = "MateGroup" Then

                         Debug.Print SwFeat.Name

                End If

                Do While Not SwSubFeat Is Nothing

                    Debug.Print SwSubFeat.Name, SwSubFeat.GetTypeName

                    If SwSubFeat.GetTypeName = "Mate" Then

                         Debug.Print SwSubFeat.Name

                    End If

                    Set SwSubFeat = SwSubFeat.GetNextFeature


                Set SwFeat = SwFeat.GetNextFeature


      End Sub