MACRO LIBRARY

Get the feature information for a component

Free public access. No account or subscription required.

Files

Get the feature information for a component

Code

'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
'Gives a list of the features in the selected component. However this does not include mates. _
    To get mates you need to search the entire feature tree for the Mates folder or get all _
    of the components and then get all of the mates from each component.
'Results: see immediate window
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component2
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    
    Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, -1)
    Set swFeat = swComp.FirstFeature
    While Not swFeat Is Nothing
        Debug.Print swFeat.Name
        Set swFeat = swFeat.GetNextFeature
    Wend
End Sub