Hello,
For some drawings, but not all, I get an exception from Inventor._Document.Update() and would appreciate some troubleshooting help.
The exception I get is a COMException with "Catastrophic failure" (E_UNEXPECTED). I would like to get some more details why it fails, but I have no idea how to troubleshoot further.
First some background. I want to programmatically rename a drawing and some files it references.
For instance, I have a drawing "x.idw", containing an assembly "y.iam". The assembly contains a part "z.ipt". So, I have a hierarchy like:
x.idw -> y.iam -> z.ipt
After renaming, I want the names to be:
x2.idw -> y2.iam -> z2.ipt
I run this code in an Inventor Addin (implementing ApplicationAddInServer), so I run this in process and I use the normal inventor API (Apprentice is not involved). I have a button that I press to run my code.
I start with no open documents. Then I programmatically open 1 file at the time with Documents.Open(filename, false); // false = open hidden
In this case with "x.idw -> y.iam -> z.ipt" my code would basically run the following scenario.
ReplaceReferences is a method that iterates file.ReferencedFileDescriptors and calls ReplaceReference with the new name.
_Document doc;
doc = Documents.Open("z.ipt");
doc.Update();
doc.SaveAs("z2.ipt");
doc.Close(false);
doc = Documents.Open("y.iam");
ReplaceReferences(doc, "z.ipt", "z2.ipt");
doc.Update();
doc.SaveAs("y2.iam");
doc.Close(false);
doc = Documents.Open("x.idw");
ReplaceReferences(doc, "y.ipt", "y2.ipt");
doc.Update(); <== throws exception for some files.
doc.SaveAs("x2.idw");
doc.Close(false);
If I leave doc.Update() out, I get a dialog after opening the drawing again that my model needs to be updated. That is why I added the call to doc.Update().
If I swallow the COMException from Update and continue with SaveAs and Close, I can open the document and all references seem to be changed. However, there is a "Red flash" icon on "Sheet1". The red flash icon has a hint that says that the model might need updating, but I have no idea about what to update.
Before my "renaming", the offending drawing doesn't have a red flash, so it seems like I'm causing the red flash to appear in some way.
My questions:
* How can I get more information about why Update() throws an exception? Or are there alternatives that are better than calling Update()?
* What does the "Red flash" icon mean?
Kind Regards,
Mattias