SaveAsInventorDWG() Without Save Dialog?

SaveAsInventorDWG() Without Save Dialog?

SometimesInventorMakesMeAngry
Advocate Advocate
631 Views
3 Replies
Message 1 of 4

SaveAsInventorDWG() Without Save Dialog?

SometimesInventorMakesMeAngry
Advocate
Advocate

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.

0 Likes
Accepted solutions (1)
632 Views
3 Replies
Replies (3)
Message 2 of 4

AlexKorzun
Autodesk
Autodesk
Accepted 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)

 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

0 Likes
Message 3 of 4

SometimesInventorMakesMeAngry
Advocate
Advocate
Thanks for the quick response. I will try this tomorrow and report back.
0 Likes
Message 4 of 4

SometimesInventorMakesMeAngry
Advocate
Advocate

I tested this and it works perfectly. Completely forgot about it. Thank you!

0 Likes