ApplicationEvents.OnCloseDocument cannot be canceled

ApplicationEvents.OnCloseDocument cannot be canceled

yan.gauthier
Advocate Advocate
492 Views
3 Replies
Message 1 of 4

ApplicationEvents.OnCloseDocument cannot be canceled

yan.gauthier
Advocate
Advocate

Hi,

 

I am having a problem with my addin on Inventor 2022.2.2:

 

I subscribre to this the OnCloseDocument event, my code steps into it. set the HandlingCode to kEventCanceled, but then Inventor still fires the kAfter event instead of kAbort and closes the document...

 

private void ApplicationEvents_OnCloseDocument(_Document DocumentObject, string FullDocumentName, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
        {
            if (BeforeOrAfter == EventTimingEnum.kBefore)
            {
                HandlingCode = HandlingCodeEnum.kEventCanceled;
            }
            else
            {
                HandlingCode= HandlingCodeEnum.kEventHandled;
            }
        }

 

Is this a bug? How can we flag this to Autodesk ?

0 Likes
Accepted solutions (1)
493 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor
Think that you can't cancel an event.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 4

yan.gauthier
Advocate
Advocate

Autodesk Documentation about it says that you can:

 

https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-A5DA37D6-BA28-46B0-B4AE-B47D3A6A4D1C

 

This event supports the ability to cancel the close. By setting this argument to kEventCanceled when the BeforeOrAfter argument is kBefore Inventor will abort the close. When the close is cancelled, this event is fired again but the BeforeOrAfter argument will have a value of kAbort.

 

Message 4 of 4

yan.gauthier
Advocate
Advocate
Accepted solution

After corresponding with Autodesk about the issue, they told me that they are making progress understanding the issue, but there is no fix yet.

 

Apparently, the 3D-Annotation addin might be the culprit here. They say I could disable this addin to fix the issue.

 

Since I am using 3D-Annotations, I will wait and hope for a fix in an upcoming update.

 

 

0 Likes