Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: karolis.s

Hi @karolis.s.  Your first image shows that the error is happening when it tries to close a document, and the second image shows what looks like you being in 'edit mode' of a part type assembly component, while an assembly is actually the 'active' document.  When you enter and exit the 'edit mode' of that part type component while an assembly is 'active', that will change the environment, triggering event handler to run.  If that part is still being referenced by the assembly, you will not be able to truly close it.  If you open the document visibly, by specifying True for Visible when opening it, then using Close on that document would normally just turn its visibility back off, but it would remain open (or at least initiated) in the background, because of it still being actively referenced by the assembly.  Closing whatever document was the 'active edit document' every time the environment changes away from a part editing one does not sound like a good idea to me, but I do not know what your design intent is, so maybe with a bit of further development it would not be bad at all.

 

Edit:  Also, reviewing what a Document object is may help in areas like this.  Below is a link to the online help page for the basic Document Inventor API object.  It says that it represents something that is already 'in memory'.  Then, if you look at its Open property, which is a ReadOnly Boolean, you will see that the primary two possible states of a Document object are 'Initiated' and 'Open'.  And if just initiated, then accessing any of its properties will cause it to Open.  And again, open does not always mean visible on your screen, or that there will be a Document tab for it showing.  Any time you open either an assembly, or a drawing, that action also initializes all of their referenced documents.  You will see those numbers at the right end of the Inventor 'status bar' (usually at the bottom right of the screen).

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-Document 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)