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: 

AllLeafOccurrences for subassembly

1 REPLY 1
SOLVED
Reply
Message 1 of 2
virajendran4WGSB
244 Views, 1 Reply

AllLeafOccurrences for subassembly

Hi forum,

 

I am trying to collect all leaf occurrence inside a sub assembly by running the code on the referenced main assembly in the drawing view. 

I've tried this code but it doesn't work. The reason it doesn't work is because I tried to typecast the component occurrence as a assembly document to get all leaf occurrence for the sub assembly

 

Here's my sample code :

 

AssemblyDocument AsmDoc=oview.ReferencedDocumentDescriptor.ReferencedDocument;
AssemblyComponentDefinition AsmCompDef = AsmDoc.ComponentDefinition;
ComponentOccurrences comocc = AsmCompDef.Occurrences;
ComponentOccurrence subocc = AsmCompDef.Occurrences[1];
AssemblyDocument assem = (AssemblyDocument)subocc;
AssemblyComponentDefinition asemdef = assem.ComponentDefinition;
ComponentOccurrences comoc = asemdef.Occurrences;
ComponentOccurrencesEnumerator leaf = comoc.AllLeafOccurrences;

Thanks,

Vidhuran

1 REPLY 1
Message 2 of 2

You cant cast a occurrence to a document. But the occurrence has some properties to get the document. Have a look at this (not tested) code.

AssemblyDocument AsmDoc = oview.ReferencedDocumentDescriptor.ReferencedDocument;
AssemblyComponentDefinition AsmCompDef = AsmDoc.ComponentDefinition;
ComponentOccurrences comocc = AsmCompDef.Occurrences;
ComponentOccurrence subocc = AsmCompDef.Occurrences[1];
AssemblyDocument assem = (AssemblyDocument)subocc.ReferencedDocumentDescriptor.ReferencedDocument;
AssemblyComponentDefinition asemdef = assem.ComponentDefinition;
ComponentOccurrences comoc = asemdef.Occurrences;
ComponentOccurrencesEnumerator leaf = comoc.AllLeafOccurrences;

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

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

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report