Valued Contributor
Posts: 64
Registered: ‎11-01-2001
Message 1 of 5 (222 Views)
Accepted Solution

Trigger Autosave

222 Views, 4 Replies
09-27-2013 02:34 AM



is it possible to trigger an Autosave before executing my vb.net-code? I'm rather new to vb.netcode and in case of an unexpexted error AutoCad sometimes crashes. If I Could trigger an auto-save before the code is run, no information in the drawing is lost, but can be obtained in an autosave-file.


I cannot trigger a Save of SaveAs, because i don't know if the user wanted to save the drawing, for examples if the user reads an older drawing, removes/deletes objects etc, but is unaware of the drawing being saved, it could result in problems.


kind regards Wouter

*Expert Elite*
Posts: 2,082
Registered: ‎04-29-2006
Message 2 of 5 (210 Views)

Re : Trigger Autosave

09-27-2013 03:20 AM in reply to: wbdehaan



what about using SaveAs() with a suffixed filename?

Gilles Chanteau
Valued Contributor
Posts: 64
Registered: ‎11-01-2001
Message 3 of 5 (203 Views)

Re: Trigger Autosave

09-27-2013 04:00 AM in reply to: wbdehaan

Thanks for you reply,


if I use saveas with a prefix, the active drawing is saved in that location, if the user will save afterwards, thinking that it is saved in the original location, it will actually be saved in de new autosave-directory, which is not an option.


If it is possible to do a save-as with a prefix, and then reset the drawing-name and path to the original drawing & location, it is a solution, but I don't know how to do that, 





Posts: 25
Registered: ‎09-28-2004
Message 4 of 5 (188 Views)

Re: Trigger Autosave

09-27-2013 05:27 AM in reply to: wbdehaan

If you use the SaveAs of the Database ( and not of the document), then the Database is saved without changing the name of the drawing. So the drawing will still be saved under it's old name, if the user pushes the save button.


Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database;

string f1 = doc.Name;    
string f2 = db.Filename; // should be the same then f1
db.SaveAs("D:\\Test.dwg", DwgVersion.Current);

// doc.Name is still f1
// but db.Filename is "D:\\Test.dwg"

 A save Command from the user will use the doc.Name, not the filename of the db.

Valued Contributor
Posts: 64
Registered: ‎11-01-2001
Message 5 of 5 (169 Views)

Re: Trigger Autosave

09-27-2013 07:18 AM in reply to: wbdehaan

It works, thank you very much!



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.