Active Member
Posts: 8
Registered: ‎10-12-2006
Message 1 of 4 (150 Views)

Close & Save

150 Views, 3 Replies
01-04-2007 04:02 AM
Is there any way to close all opened files (drawing files)?
How can I save a drawing file programmatically?

Thank you,
Valued Contributor
Matt S
Posts: 64
Registered: ‎05-05-2004
Message 2 of 4 (150 Views)

Re: Close & Save

01-05-2007 12:50 PM in reply to: Babak
Below is a way to iterate through all open drawings and save, close and do other things. There has to be a better way to do this, but this was the easiest at the time.

[CommandMethod("DwgScale10", CommandFlags.Session)]
public void sveDwgScale10()
int i = 0;
Document curDoc;
DocumentCollection docCol;
docCol = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;

foreach (Document doc in docCol)
docCol.MdiActiveDocument = doc;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

doc.SendStringToExecute("scale all 0,0,0 10.0 ", false, false, true);
doc.SendStringToExecute("zoom e ", false, false, true);
doc.SendStringToExecute("qsave ", false, false, true);
doc.SendStringToExecute("close ", false, false, false);

Active Member
Posts: 8
Registered: ‎10-12-2006
Message 3 of 4 (150 Views)

Re: Close & Save

01-06-2007 08:22 AM in reply to: Babak
Thank you very much for your reply.
But what other better way? :smileywink: I need to save drawing automatically after each changes.

Thank you again,
Distinguished Contributor
Posts: 1,691
Registered: ‎12-15-2003
Message 4 of 4 (150 Views)

Re: Close & Save

01-07-2007 02:03 PM in reply to: Babak
Using the CloseAndSave method of Autodesk.AutoCAD.ApplicationServices.Document instead of resorting to SendStringToExecute.

Regards - Nathan
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.