I'm trying to identify different occurrences in my assembly and its subassemblies,
so far I'm traversing down the assembly tree like this;
Sub Main() On Error Resume Next
Dim oDoc As AssemblyDocument oDoc = ThisDoc.Document oDoc.ObjectVisibility.AllWorkFeatures() = True Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = oDoc.ComponentDefinition oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate Dim occBoolean As Boolean occBoolean = False Dim oOcc As Inventor.ComponentOccurrence For Each oOcc In oAsmCompDef.Occurrences oOcc.SetDesignViewRepresentation("Default", True) MsgBox(oOcc.Definition) If oOcc.SubOccurrences.Count = 0 Then Else Call processAllSubOcc(oOcc) End If Next InventorVb.DocumentUpdate() End Sub Private Sub processAllSubOcc(Occ As Inventor.ComponentOccurrence) Dim oSubCompOcc As ComponentOccurrence For Each oSubCompOcc In Occ.SubOccurrences
If oSubCompOcc.SubOccurrences.Count = 0 Then Else oSubCompOcc.Visible = occBoolean Call processAllSubOcc(oSubCompOcc) End If Next End Sub
The problem is that I can't tell the occurrences apart as they are just "occurrences". Well, I can tell the assemblies and part documents by looking at the DefinitionDocumentType property of the component occurrence, but what about work features? How do I identify work planes or axes as occurrences in an assembly?
Help is much appreciated!
Hi,
I'm not sure what exactly you need but the best thing to get familiar with the API is to use VBA:
http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html
If you need to get to a work feature then you need to go inside the definition of the occurrence (inside the document) and then get a proxy for it:
http://adndevblog.typepad.com/manufacturing/2013/07/occurrences-contexts-definitions-proxies.html
and
http://adndevblog.typepad.com/manufacturing/2014/09/select-plane-of-given-part-occurrence.html
Cheers,
Thanks a million! I will look into your suggestions, especially the VBA Watches. This far I've only been using the Inventor help and VBA editor object browser to find my way around. I also got the API object model which is of great help, but sometimes I find it really difficult to find specific objects or properties, so your suggestions will be of much help.