Identifying occurrences in assembly

Identifying occurrences in assembly

Anonymous
Not applicable
423 Views
2 Replies
Message 1 of 3

Identifying occurrences in assembly

Anonymous
Not applicable

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!

0 Likes
424 Views
2 Replies
Replies (2)
Message 2 of 3

adam.nagy
Autodesk Support
Autodesk Support

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

Anonymous
Not applicable

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.

0 Likes