Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Identifying occurrences in assembly

2 REPLIES 2
Reply
Message 1 of 3
TommySWE
284 Views, 2 Replies

Identifying occurrences in assembly

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!

2 REPLIES 2
Message 2 of 3
adam.nagy
in reply to: TommySWE

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,



Adam Nagy
Autodesk Platform Services
Message 3 of 3
TommySWE
in reply to: adam.nagy

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report