Autosave

Autosave

cvanriper
Enthusiast Enthusiast
529 Views
7 Replies
Message 1 of 8

Autosave

cvanriper
Enthusiast
Enthusiast

I want to write a lisp that would initiate an auto save every time I close a drawing. Is there a way to manually initiate an auto save?

0 Likes
Accepted solutions (1)
530 Views
7 Replies
Replies (7)
Message 2 of 8

paullimapa
Mentor
Mentor

What's the purpose of initiating an autosave prior to a close?

Why not just do a Qsave?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 8

Kent1Cooper
Consultant
Consultant

It would certainly be possible [you may find such a thing in this Forum already] to make an AutoLisp file that would UNDEFINE the CLOSE command, and define it anew with a built-in QSAVE before CLOSEing, and to have that redefinition loaded automatically in every drawing you open or create.  But would you really want that -- saving every drawing every time you Close it without asking whether you want to?  I open a drawing just to copy something out of it to paste into another drawing, or similar things, often enough that I wouldn't want that to be automatic -- I wouldn't have any way of knowing when I last actually did meaningful work in it if it was saved even when I didn't actually do anything.

 

And I'd have to experiment [maybe someone out there already knows] to see whether it would require you to type in CLOSE or use a ribbon item -- it may not be possible to have picking the X at upper right invoke a redefined CLOSE command.

 

You would still be able to Close without saving when you want to do so, as long as you remember that you need to type in .CLOSE with the preceding period to force the use of the native command instead of the redefinition.

Kent Cooper, AIA
0 Likes
Message 4 of 8

cvanriper
Enthusiast
Enthusiast
Fail safe
0 Likes
Message 5 of 8

cvanriper
Enthusiast
Enthusiast

There are many times I forget to QSAVE while I am working. We name our files according to the sheet number and I often reference other projects for things, so I might have more than one file with the same name open. I obviously don't want to overwrite my reference dwg file, but DO want to save the changes to the file for the project I am working on. I still want the notification to ask me if I want to save when I close the drawing, but I also want to have an autosave occur, in the background, that would back up my changes should I accidentally click NO when I am asked if I want to save (this has occurred a number of times, because I do stupid things from time to time). I changed the autosave interval from 5 minutes to 2, but that short pause that happens while it is saving usually occurs in the middle of a command...so annoying. Maybe there is a better failsafe that can be incorporated in this, but this is what my brain keeps circling back on as a solution.

0 Likes
Message 6 of 8

pendean
Community Legend
Community Legend
Accepted solution

@cvanriper wrote:

There are many times I forget to QSAVE while I am working. We name our files according to the sheet number and I often reference other projects for things, so I might have more than one file with the same name open. I obviously don't want to overwrite my reference dwg file, but DO want to save the changes to the file for the project I am working on. I still want the notification to ask me if I want to save when I close the drawing, but I also want to have an autosave occur, in the background, that would back up my changes should I accidentally click NO when I am asked if I want to save (this has occurred a number of times, because I do stupid things from time to time). I changed the autosave interval from 5 minutes to 2, but that short pause that happens while it is saving usually occurs in the middle of a command...so annoying. Maybe there is a better failsafe that can be incorporated in this, but this is what my brain keeps circling back on as a solution.


It appears you may not know that "autosave" is not a substitution for a QSAVE, and that if you close out of your DWG deliberately (aka answer "no") your "autosave" is actually deleted by the program on purpose. Yes?

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Understanding-Auto...

0 Likes
Message 7 of 8

cvanriper
Enthusiast
Enthusiast

I do not typically explore the sv$ files and I did not realize this. Thank you

0 Likes
Message 8 of 8

Kent1Cooper
Consultant
Consultant

If that's really what you want to do, try this [limited testing]:

(command "_.undefine" "CLOSE")
(defun C:CLOSE () (command "_.qsave" "_.close"))

But some noteworthy things:

 

You need to ensure that it gets loaded in every drawing [such as by an acaddoc.lsp file], because [within the same AutoCAD session at least] the Undefining "sticks" from one drawing to another that was already open at the time of loading, but the new definition does not, and needs to be loaded.  If you don't, you'll get an unknown-command error when you pick on the X at upper right for the drawing, or type CLOSE.

 

It works for that X at upper right in the individual drawing window, or in the upper-left-big-A pull-down's Close option for the current drawing, both of which apparently invoke just CLOSE, and therefore use the new definition.  But it does not work with the bigger X at upper right of the AutoCAD program, or the big-A pull-down's Close option for all drawings, which apparently invoke .CLOSE digging into the native command, so it doesn't include the QSAVE, and it asks if you want to save.

 

If you might use QUIT instead of CLOSE, you need to do the same Undefine/redefine on that command, too -- QUIT is not just a stand=in alternative command name for CLOSE, since it exits not just the drawing but the program.  But if you have more than one drawing open, and other drawings than the current one have been edited since last saved, you will still be asked about saving them, and this was not avoided by putting the SAVEALL Express Tool into the redefinition.

Kent Cooper, AIA
0 Likes