View Full Version : LISP - Automatic Save that runs at set intervals
tyeelaw13
2005-10-19, 05:11 PM
Is there any way to have a lisp routine run at a set interval? I am looking to see if i can do a save every 10 minutes with a different name each time. Since AutoCAD doesn't save the backup saves when it closes, several people in my workplace are looking for a way to save a drawing that is in a design phase so they might be able to revert back to undo changes that were made.
Thank you in advance.
I would think you would need to look into reactors.
Mike.Perry
2005-10-19, 09:21 PM
Hi
Here is something from Peter Jamtgaard (an old LISP Guild post) that might prove an interesting starting point...
VLR_AUTO_SAVE.LSP is a program that will save after every 10 commands. It will not save while a lisp program is being executed.
Try it out and let me know if you like it or not, bugs, you know.
(defun C:VLR_AUTO_SAVE ()
(vl-load-com)
(setq ASRXN1 (vlr-editor-reactor nil '((:vlr-commandended . ASCOM1)))
ASRXN2 (vlr-lisp-reactor nil '((:vlr-lispWillStart . ASCOM2)))
ASRXN3 (vlr-lisp-reactor nil '((:vlr-lispended . ASCOM3)))
)
)
(defun ASCOM1 (CALL CALLBACK)
(if (not LISPRUN)
(progn
(cond
((= (car CALLBACK) "SAVE")
(setq ASCOUNT 0)
)
((= (car CALLBACK) "QSAVE")
(setq ASCOUNT 0)
)
)
(if (not ASCOUNT)
(setq ASCOUNT 0)
(if (> ASCOUNT 9)
(progn
(setq ASCOUNT 0)
(vla-save (vla-get-activedocument (vlax-get-acad-object)))
(print "AutoSave")
)
(progn
(setq ASCOUNT (1+ ASCOUNT))
(print ASCOUNT)
)
)
)
)
)
)
(defun ASCOM2 (CALL CALLBACK)
(setq LISPRUN 'T)
)
(defun ASCOM3 (CALL CALLBACK)
(setq LISPRUN nil)
)Have a good one, Mike
peter
2005-10-20, 02:57 PM
try this version
jwanstaett
2005-10-20, 03:28 PM
If you are use AutoCAD 2000 and up all you need to do is open options and on open and save tab set automatic save to 10 minutes and select the check box for automatic save and create backup copy with each save. on the files tab set the Automatic Save File Location to the path where to save the files. AutoCAD will do the job for you. The files will be save with a name like filename_1_1_1427.sv$ or filename_1_1_2427.Bak use the date modified is the time the file was saved. To to revert back change the sv$ or bak to dwg and open the file.
Note: if thefile is not open for 10 min the autosave will not take place
Mike.Perry
2005-10-20, 07:05 PM
If you are use AutoCAD 2000 and up all you need to do is open options and on open and save tab set automatic save to 10 minutes and select the check box for automatic save and create backup copy with each save. on the files tab set the Automatic Save File Location to the path where to save the files. AutoCAD will do the job for you. The files will be save with a name like filename_1_1_1427.sv$ or filename_1_1_2427.Bak use the date modified is the time the file was saved. To to revert back change the sv$ or bak to dwg and open the file.
Note: if thefile is not open for 10 min the autosave will not take placeHi
Under most normal conditions the SV$ and BAK files will automatically be deleted once a clean exit from the drawing file(s) occurs.
ID: TS68939 - BAK files created as backups of SV$ automatic save files are not deleted after exit (http://usa.autodesk.com/adsk/servlet/ps/item?id=2865093&linkID=2475323&siteID=123112)
ID: TS73581 - Automatic save files (SV$ files) no longer kept after normal exit (http://usa.autodesk.com/adsk/servlet/ps/item?id=2892702&linkID=2475323&siteID=123112)
ID: TS20536 - Automatic save (SV$) files (http://usa.autodesk.com/adsk/servlet/ps/item?id=2897386&linkID=2475323&siteID=123112)
Have a good one, Mike
kennet.sjoberg
2005-10-20, 07:57 PM
Hi
Under most normal conditions the SV$ and BAK files will automatically be deleted ...
mnnnnot really.. the bak file in not deleted after a normal exit, but you can tell the system to not create it.
: ) Happy Computing !
kennet
Mike.Perry
2005-10-20, 07:59 PM
mnnnnot really.. the bak file in not deleted after a normal exit, but you can tell the system to not create it.Hi
The BAK file will be a copy of the drawing file from the Save before Closing, therefore only one BAK will exist... totally pointless in the context of this thread...
Have a good one, Mike
I think that THIS (http://www.theswamp.org/forum/index.php?topic=4735.15) thread over at theSwamp.org has exactly what you are looking for. The post by Kerry, specifically.
Jeff
kennet.sjoberg
2005-10-20, 10:07 PM
Hi
The BAK file will be a copy of the drawing file from the Save before Closing, therefore only one BAK will exist... totally pointless in the context of this thread...
Have a good one, Mike
Absolutely correct, I was just correcting your statement, about automatically deleting *.BAK files.
: ) Happy Computing !
kennet
tyeelaw13
2005-10-20, 10:23 PM
Thanks a bunch. Running in autodcad 2005 now for about 8 months has irked a few people since the sv$ files disappear, and most of them were unaware of that. When designing new plans, sometimes people get too far ahead of themselves, and then when they can't revert back to a sv$ file, they freak out. I will try a few of the lsp routines and see what works best!
Mike.Perry
2005-10-20, 11:03 PM
Absolutely correct, I was just correcting your statement, about automatically deleting *.BAK files.Hi
My original statement was correct...
Under most normal conditions...BAK files that are created in the "SaveFilePath" location are normal automatically deleted when Closing a drawing file cleanly.
The BAK file normal located in the current working drawing directory (unless something like Express Tools "MoveBAK" has been used) is a separate beast ( as mentioned above ).
Have a good one, Mike
kennet.sjoberg
2005-10-20, 11:31 PM
Hi . . . Have a good one, Mike
I am sorry, I still do not understand what you mean with "normal" ( Express Tools NOT included )
For me there is only the system variable ISAVEBAK to create a BAK file or not.
Can you please tell me how to do automatically delete the BAK file at exit when ISAVEBAK is set to 1.
: ) Happy Computing !
kennet
Mike.Perry
2005-10-20, 11:53 PM
I am sorry, I still do not understand what you mean with "normal" ( Express Tools NOT included )
For me there is only the system variable ISAVEBAK to create a BAK file or not.
Can you please tell me how to do automatically delete the BAK file at exit when ISAVEBAK is set to 1.Hi
I have ISaveBAK = 1
I have SaveFilePath = C:\Temp_Acad\Auto_Save
BAK files are therefore created in the current working directory (when a Save is issued).
SV$ and BAK files are created in "C:\Temp_Acad\Auto_Save", under normal conditions, these files are automatically deleted upon a clean Close (exit) from a drawing file. BUT! sometimes the BAK files are not automatically cleared, even though a clean Close (exit) has occurred (please refer to attached screen capture).
Regardless, in the context of this thread, all of what I have said in this post is totally irrelevant as it does not help "yeelaw13" with his / her query.
Have a good one, Mike
kennet.sjoberg
2005-10-21, 12:30 AM
Hi
... is totally irrelevant as it does not help "yeelaw13" with his / her query.
Have a good one, Mike
Yes you can move or delete this "*.BAK" tread,
BUT the bak file will always be there when ISAVEBAK is set to 1
: ) Happy Computing !
kennet
Mike.Perry
2005-10-21, 12:40 AM
BUT the bak file will always be there when ISAVEBAK is set to 1Hi
Yes, in the current working directory... we agree on that.
I was trying to point out, BAK are also created in the directory that SaveFilePath points to ( in my case "C:\Temp_Acad\Auto_Save" ).
Have a good one, Mike
kennet.sjoberg
2005-10-21, 12:49 AM
Hi
Yes, in the current working directory... we agree on that.
I was trying to point out, BAK are also created in the directory that SaveFilePath points to ( in my case "C:\Temp_Acad\Auto_Save" ).
Have a good one, Mike
Well there is "SAVEFILEPATH" , "SAVEFILE" , "ISAVEBAK" and "ENDOFROAD"
;) Happy Computing !
kennet
peter
2005-10-21, 06:42 PM
If you wanted to have your own program do this, I have corrected the program I posted the other day. I was in a rush and didn't properly debug it until today.
ccowgill
2005-10-27, 12:21 AM
Is is possible to modify the reactor so it goes to a particular folder. For example: you have an auto save folder that all of your auto saves go to, that way you can clean it out as necessary. I have my auto save folder on my local hard drive instead of our network so I dont clutter up our network, when you have a set of 70-80 drawings and forget to erase the bak's it doubles your drive usage.
Is is possible to modify the reactor so it goes to a particular folder. For example: you have an auto save folder that all of your auto saves go to, that way you can clean it out as necessary. I have my auto save folder on my local hard drive instead of our network so I dont clutter up our network, when you have a set of 70-80 drawings and forget to erase the bak's it doubles your drive usage.
The reactor is not the controlling factor. The reactor only calls the specified lisp routine when an event triggers the reactor.
The specified lisp routine controls where the file is saved.
So the answer is yes the location can be changed to a specified location. It's just not controlled in the reactor.
ccowgill
2006-10-25, 02:47 PM
The auto save.lsp works fine, I figured out the save location. How would I modify the reactor so it doesn't run the auto save when the command that was issued was open, or quit. I notice that sometimes I have to wait for an auto save to complete before a drawing will close, or even when I am opening a new drawing, sometimes the command hangs because it is waiting for the auto save to complete.
kennet.sjoberg
2006-10-25, 11:24 PM
. . .How would I modify the reactor so it doesn't run the auto save when the . ..
The reactor do only control when to trigger and run a function/lisp-program.
The function/lisp-program do the control
: ) Happy Computing !
kennet
BTW if you set the autosave time to 20 minutes, switch to an other task in 30 minutes
and then return to the first task...the autosave will run...if it is not set to OFF.
ccowgill
2006-10-26, 01:42 PM
Isn't the reactor what causes the program to initiate the auto save, it doesn't automatically save every 10 minutes, it saves after the next command that is initiated after 10 minutes, so if you have your drawing open and leave for 1/2 hour, when you come back, it hasn't auto saved, but if you do anything, it will proceed to auto save following the command.
kennet.sjoberg
2006-10-26, 02:02 PM
Isn't the reactor what causes the program to initiate the auto save, it doesn't automatically save every 10 minutes, it saves after the next command that is initiated after 10 minutes, so if you have your drawing open and leave for 1/2 hour, when you come back, it hasn't auto saved, but if you do anything, it will proceed to auto save following the command.
BTW if you set the autosave time to 20 minutes, switch to an other task in 30 minutes
and then return to the first task...the autosave will run...if it is not set to OFF.
: ) Happy Computing !
kennet
ccowgill
2006-10-26, 11:39 PM
Command: N
QSAVE
Command: *Cancel*
Command: *Cancel*
Command: _quit
Initiating AutoSave Function on File <c:\autocad auto save\BAKUP DWG\X5227.DWG_20061026.1735.dwg>:
Command:
This is what I wish to prevent, I save, then I exit the drawing and have to wait for the autosave produced by autosave.lsp to complete.
kennet.sjoberg
2006-10-27, 12:19 AM
This is what I wish to prevent, I save, then I exit the drawing and have to wait for the autosave produced by autosave.lsp to complete.
Turn Autosave OFF
: ) Happy Computing !
kennet
kennet.sjoberg
2006-10-27, 08:34 AM
More info. . .
SAVETIME System Variable
Type: Integer
Saved in: Registry
Initial value: 10
Sets the automatic save interval, in minutes.
0 Turns off automatic saving.
>0 Saves the drawing at intervals specified by the nonzero integer automatically
The SAVETIME timer starts as soon as you make a change to a drawing.
It is reset and restarted by a manual QSAVE, SAVE, or SAVEAS.
The current drawing is saved to the path specified by the SAVEFILEPATH system variable.
The file name is stored in the SAVEFILE system variable.
(setvar "SAVETIME" 0 ) ; = System Autosave OFF
: ) Happy Computing !
kennet
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.