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: 

Get level of active edit document occurrence in parent assembly

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
matt_jlt
197 Views, 2 Replies

Get level of active edit document occurrence in parent assembly

I am  to determine how deep into the assembly occurrence structure that an "active edit document" is which means i need to get its occurrence in the parent assembly.

 

When i get the "active edit document", it is a document and not an occurrence of the parent occurrence. I don't know how i can get its relevant occurrence.

 

I would try using the "active edit object" but the user could also be editing an assembly level sketch or some other feature and it would be problematic.

 

Does anyone have a solution for this?

 

Thanks, Matt.

 

Example

 

Assembly A (Parent)

      Assembly B:1 (Child assembly occurrence) - i could be editing this assembly

      Assembly C:1 (Child assembly occurrence)

             Assembly D:1 (Child assembly occurrence) - i could also be editing this assembly

2 REPLIES 2
Message 2 of 3
Andrii_Humeniuk
in reply to: matt_jlt

Hi @matt_jlt . I hope I understood you correctly. This is an example of iLogic code that can retrieve the level of an actively edited document in an assembly:

Dim oInvApp As Inventor.Application = ThisApplication
Dim oADoc As AssemblyDocument = TryCast(oInvApp.ActiveDocument, AssemblyDocument)
If oADoc Is Nothing Then Exit Sub
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oEditOcc As ComponentOccurrence = oADef.ActiveOccurrence
If oEditOcc Is Nothing Then Exit Sub
Dim oParentOcc As ComponentOccurrence
MessageBox.Show(oEditOcc.Name, "Avtive Edit Occurrence:")
Dim iLevel As Integer = 1
Do
	oParentOcc = oEditOcc.ParentOccurrence
	MessageBox.Show(oParentOcc.Name, "Parent Occurrence - Level " & iLevel & ":")
	iLevel += 1
	oEditOcc = oParentOcc
Loop While oEditOcc.ParentOccurrence Isnot Nothing
MessageBox.Show(oADoc.DisplayName, "Top Level Document - Level " & iLevel & ":")

 

Andrii Humeniuk - Leading design engineer

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 3
matt_jlt
in reply to: matt_jlt

That's exactly what i was after, thankyou. I didnt know there was an "ActiveOccurrence" object.

 

Thanks again, Matt.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report