It is possible to access and get information from virtual parts in an assembly using Apprentice. It’s basically the same as in Inventor with a slight difference because all of the same types aren’t defined within Apprentice. Rather than go through a lengthy discussion, here’s some VB.NET code that demonstrates getting iProperties from an assembly and correctly handling virtual components.
Public Sub TestVirtual()
' Create Apprentice and open the assembly.
Dim app As ApprenticeServerComponent
app = New ApprenticeServerComponent
Dim doc As ApprenticeServerDocument
doc = app.Open("C:\Temp\TestAssembly.iam")
' Iterate through the occurrences in the assembly.
Dim occ As ComponentOccurrence
For Each occ In doc.ComponentDefinition.Occurrences
Dim def As ComponentDefinition
def = occ.Definition
' Check to see if this occurrence is for a virtual part.
If TypeOf def Is VirtualComponentDefinition Then
' Get the virtual component definition since this
' is what provides access to the property sets.
Dim virtualDef As VirtualComponentDefinition
virtualDef = def
' Call the function to get the properties.
Call ShowProperties(virtualDef.PropertySets)
Else
' Get the associated document since this is what
' provides access to the property sets.
Dim refDoc As ApprenticeServerDocument
refDoc = def.Document
' Call the function to get the properties.
Call ShowProperties(refDoc.PropertySets)
End If
Next
End Sub
' Sample to show getting properties.
Private Sub ShowProperties(PropSets As PropertySets)
Dim designTracking As PropertySet
designTracking = PropSets.Item("Design Tracking Properties")
Debug.Print("Part Number: " & _
designTracking.Item("Part Number").Value)
End Sub
-Brian