Unhandled Exception in API method DrawingDocument.SaveAs: Inconsistent Memory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Greetings!
Intro: I'm running into an issue with some unexpected API behavior that causes Inventor 2018.3 to crash in a batch processing application I'm developing. While I figure out a work-around, I wanted to throw this issue out there to the community to see if anyone had any ideas on the root cause and hopefully get some engagement from Autodesk Inventor QA (since the "Bug Alert" instructs one to "Please report this to Inventor QA"). And for any Autodesk QA tuning in, this behavior has generated a slew of error reports, most notably CER_183470955...
Issue/Behavior:
After copying drawing sheet information from a legacy drawing into a new drawing, and deleting the legacy drawing, Inventor throws a "Bug Alert!" in the middle of executing the DrawingDocument.SaveAs method call--where the .SaveAs method is attempting to save the new file with the exact same name as the deleted file.
NOTE 1: I have a version of this script already in production that executes this program flow without issue every time, but it was only designed to update one legacy drawing file at a time. In addition, I can execute the current batch processing version of the script on some files and it works repeatably without issue--so I know the program flow is capable of working.
NOTE 2: You can see from the picture below that the .SaveAs method seems to create a temporary file for the new document undergoing the initial document save (~0002_703(29_test).dwg.2152.newVer.tmp) but prior to Inventor crashing.
(NOTE 3: the other temporary file appearing directly above belongs to the 0002_702(28_test).dwg file, which is open. I have tried closing each file individually at the end of the loop and leaving them open in the session memory, but the result is the same: Inventor crashes. So I don't have reason to believe that part of the implementation has any affect on the outcome.)
Issue Details: In a nutshell, all i'm trying to do is:
- Take a list of user-selected files that are legacy drawings (not to current standards)
- Loop through each legacy drawing file and:
- Create a brand new file based on the current version of the drawing template (but has nothing on the default drawing sheet)
- Copy each legacy drawing sheet into the "new" drawing document
- Delete the legacy information that no longer applies (revision clouds, certain sketch symbols, old AutoCAD blocks, etc.)
- Delete the legacy document object (by using the FileManager object, since the Documents collection does not have a .Delete method available).
- Close the legacy document object (NOTE: the Inventor API forces the ".DeleteFile" method implementation, through the FileManager object to occur before the Document.Close method is implemented--which is what, theoretically, should "kick-out" any remaining session memory reference to the document that was deleted. Trying to execute the .Close method before the .DeleteFile method is futile whereas an automation error exception is throw and Inventor crashes.)
- Save the new document with the same full file name as the legacy file that was deleted.
- Next legacy file.
Again, this program flow works without issue when applied to a single document. I have also run tests on certain batches of legacy drawings that execute repeatably and without issue. To compound things, there was a time within the last month where the current development version of this application was tested on these same files and worked without issue.
For reference:
- All files are able to be opened in Inventor 2018.3 (thus are migrated) and have no unresolved references, etc.
- The applications are being prototype using the VBA language & development environment.
Specific test files may be available upon request to the right person (Inventor QA).
Let me know if anyone has any ideas as to what might be the root cause of this issue and that I could test for.
Thanks!
