Is it possible to use the SaveAsInventorDWG method to save an Inventor drawing (.idw or .dwg) without triggering a save dialog?
I am opening Inventor in the background with
inventorApp = (Application)System.Activator.
CreateInstance(invType);
inventorApp.Visible = false;
Then I open a drawing and try to save as an inventor drawing with
drawing.SaveAsInventorDWG(path, SaveCopyAs: true);
But I get a dialog asking if I'd like to save my changes even if I'm trying to save it as a completely different file. I've also tried
drawing.SaveAsInventorDWG(path, SaveCopyAs: false);
without luck. This doesn't happen with all drawings, but if Inventor is running in the background, it seems like no dialogs should appear if I'm not making any changes to the document. Not sure why trying to "save as" the inventor drawing to a different location dirties the document.
If I simply use the SaveAs method (instead of SaveAsInventorDWG), this problem is nonexistent. But it saves as an AutoCAD dwg with multiple files if there is more than one sheet.
Edit: I guess I could use the IsInventorDWG property and the System.IO.File.Copy method to simply copy .dwg files to a different location, but this doesn't help with .idw files.
Solved! Go to Solution.
Solved by AlexKorzun. Go to Solution.
The following code works for IDW file, with dialogs suppressed:
Dim doc As DrawingDocument = ThisDoc.Document Dim so As Boolean = ThisApplication.SilentOperation Dim newFileName As String = System.IO.Path.ChangeExtension( doc.FullFileName, ".dwg") Try ThisApplication.SilentOperation = True doc.SaveAsInventorDWG( newFileName, True) Finally ThisApplication.SilentOperation = so End Try 'MessageBox.Show( newFileName)
I tested this and it works perfectly. Completely forgot about it. Thank you!
Can't find what you're looking for? Ask the community or share your knowledge.