How to use FeatureByName in Traverse Assembly of subFeature?

FeatureByName

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swAssy                  As SldWorks.AssemblyDoc

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swComp                  As SldWorks.Component2

    Dim swFeat                  As SldWorks.Feature

    Dim i                       As Long

    Dim bRet                    As Boolean

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swAssy = swModel

    Set swSelMgr = swModel.SelectionManager

    Set swComp = swSelMgr.GetSelectedObjectsComponent(1)

    Set swFeat = swAssy.FeatureByName(swComp.Name2): Debug.Assert Not swFeat Is Nothing

    Debug.Print swFeat.Name

End Sub

SolidworksApi macros