Follow code, traverse feature tree , how to select mate feature →Distance1(a<1>,a<2>)
e.g.
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
Loop
Set SwFeat = SwFeat.GetNextFeature
Loop
End Sub
SolidworksApi macros