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
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
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.
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.