Q: How do I determine if a part is an iPart from the API? Is there a ‘type’ attribute I can read?
A: Following is a VBA code snippet which shows how to determine whether the selected part is an iPart or not.
VB.NET
Dim oDoc As AssemblyDocument = m_inventorApp.ActiveDocument
Dim oOcc As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences(1)
If oOcc.IsiPartMember Then
Dim oPCD As PartComponentDefinition = oOcc.Definition
Dim iPM As iPartMember = oPCD.iPartMember
Dim iPF As iPartFactory = iPM.ParentFactory
Debug.Print(iPF.MemberCacheDir)
End If
VBA:
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oOcc As ComponentOccurrence
Set oOcc = oDoc.ComponentDefinition.Occurrences(1)
If oOcc.IsiPartMember Then
Dim oPCD As PartComponentDefinition
Set oPCD = oOcc.Definition
Dim iPM As iPartMember
Set iPM = oPCD.iPartMember
Dim iPF As iPartFactory
Set iPF = iPM.ParentFactory
Debug.Print(iPF.MemberCacheDir)
<
p style=”line-height: normal;margin: 0cm 0cm 0pt” class=”MsoNormal”> End If

Leave a Reply