Know if a given Part Feature was created by an iFeature and which one

By Xiaodong Liang

Issue
Given a Part containing various features, how can I know which ones are the result of an iFeature and in this case, can I know which iFeature definition file (*.ide) was used to generate it?

Solution
The following code sample will print in the immediate VBA window the list of all the features contained in the current Part, that were generated by an iFeature. The last known path and filename of the parent iFeature will be printed out as well.

VBA Code:

Public Sub GetiFeatures()

    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oRefComps As ReferenceComponents
    Set oRefComps = oDoc.ComponentDefinition.ReferenceComponents
    
    Dim oiFeatureComp As iFeatureComponent
    For Each oiFeatureComp In oRefComps.iFeatureComponents
    
        Debug.Print "Feature Name: " + oiFeatureComp.Name
        Debug.Print "Generated by iFeature: " + oiFeatureComp.iFeatureTemplateDescriptor.LastKnownSourceFileName + vbCrLf
    
    Next

End Sub

 

 
VB.NET Code

Public Sub GetiFeatures()
 
    Dim oDoc As PartDocument
    oDoc = _InvApplication.ActiveDocument
 
    Dim oRefComps As ReferenceComponents
    oRefComps = oDoc.ComponentDefinition.ReferenceComponents
 
    Dim oiFeatureComp As iFeatureComponent
    For Each oiFeatureComp In oRefComps.iFeatureComponents
 
        Debug.Print("Feature Name: " + oiFeatureComp.Name)
        Debug.Print("Generated by iFeature: " + oiFeatureComp.iFeatureTemplateDescriptor.LastKnownSourceFileName + vbCrLf)
 
    Next
 
End Sub

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading