Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SaveAsInventorDWG() Without Save Dialog?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
SometimesInventorMakesMeAngry
453 Views, 3 Replies

SaveAsInventorDWG() Without Save Dialog?

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.

3 REPLIES 3
Message 2 of 4

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.

Message 3 of 4

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

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report