Inventor Customization

Active Contributor
Posts: 45
Registered: ‎08-05-2008
Message 1 of 3 (276 Views)
Accepted Solution

Issue with OnSaveDocument Event (BeforeOrAfter = kAbort)

276 Views, 2 Replies
02-27-2013 06:33 AM



I have an add-in that catches FileUIEvent.OnFileSaveAsDialog and also InventorEvent.OnSaveDocument events.  We've been using this add-in for about 5 years (with minor tweaking here and there) on everything form Inventor 2009 through 2012 and everything seems to work fine.


Recently we added a button to automate the process of exporting .dwfs.  This button also works OK, but now intermittently, after clicking the "Export DWF" button, users are unable to save.  I added some logging functions to try to figure out what is going on, and it turns out that the InventorEvent.OnSaveDocument event is being called with BeforeOrAfter set to kAbort.  The only fix seems to be restarting Inventor, which of course causes us to loose work.


I added logging to the other methods in the add-in, too, to try to figure out where the mistake is occuring, but it looks like the ONLY method being called in the InventorEvent.OnSaveDocument method.  After this starts happening, I can even create a new document (so it didn't exist at the time that the dwf was created) and I cannot save this documetn either.


I think the flow would normally be:

InventorEvent.OnSaveDocument wiht BeforeOrAfter = kBefore


InventorEvent.OnSaveDocument with BeforeOrAfter = kAfter


Since the Save As dialog never appears, it's failing even prior to the first call to OnSaveDocument.


Periodically, users report these symptoms without having created dwfs, but that seems to be the most reliable way to make it fail.


I'm thinking there may be some variable/flag that needs to be initialized somewhere?  Any ideas?






EDIT:  When this happens, I can still save the document that was exported to a dwf using the new button.  No dice on saving any other documents, regardless of whether they were open or even existed before or after the export

Active Contributor
Posts: 45
Registered: ‎08-05-2008
Message 2 of 3 (262 Views)

Re: Issue with OnSaveDocument Event (BeforeOrAfter = kAbort)

02-27-2013 07:19 AM in reply to: etckerry

It appears that having InventorApplication.SilentOperation set to True is bad...  I forgot the line at the end of the DWF exporting routine that sets this back to False.  I added it, and the issue seems to have stopped.  Hopefully this is the root cause, and hopefully this information is helpful to someone else.





Valued Contributor
Posts: 65
Registered: ‎10-16-2007
Message 3 of 3 (61 Views)

Re: Issue with OnSaveDocument Event (BeforeOrAfter = kAbort)

03-13-2014 04:54 AM in reply to: etckerry


The information was very helpful for me. I’ve spent a lot of time trying to figure out what was wrong with my code. When I read your post I understood. I tried to set SilentOperation to true at the start of OnSaveDocument and to false at the end. It seems to me as a bug in Inventor. So if Autodesk can fix it, it would be great.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community

Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor