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
Solved! Go to Solution.
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.
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.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register