I need something that Does what AUTOSAVE used to to (accidentally). Truly save a dwg as a backup (or other extension) at a set time interval...He likes every 3-5 minutes.
The person this is for, has used ACAD since before ACAD14 and USED the AUTOSAVE as most of his saving..Trying to get the REMEMBER TO SAVE OFTEN - Is NOT working!!!
He has TONS of Interruptions (calls, conference calls, e-mails, needing to get info from the Web) always happening and can easily have ACAD sitting for Hours before he can get back to it...
I don't understand how to write a LISP of Reactor routine. So if someone could get/find one for me with either a Set Timer or Qty of Commands. That would be Great.
I have printed out LOTS of the AUTOSAVE POSTS and am Still lost. Some say LISP is better, others say REACTOR. At one time I was given a LISP Command and used APPLOAD to get it into my ACAD and put it in the ''When you Begin ACAD put this in also'' spot. Not sure if that is still around and ACAD finally put what I wanted as a Command.
He runs Windows 7 and ACAD 2011 (Acad 14 commands mostly - and a few more recent ones)
I think he would like a DUEL BACKUP option also. (ei; .bak1 and .bak2 (the older one) or .sav1 and .sav2) and these Backups put back into the folder where the Dwg is. Like the .bak does now.
Timers are a pain to implement using reactors since the reactor would need to monitor the system clock at regular intervals, for example by monitoring a callback event which is likely to occur regularly.
To suggest an alternative, the following simple reactor-based code will save the current drawing after every 20 commands:
(vl-load-com) (if (null *autosave-reactor*) (setq *autosave-reactor* (vlr-command-reactor "autosave" '( (:vlr-commandended . autosave) (:vlr-commandcancelled . autosave) (:vlr-commandfailed . autosave) ) ) ) ) (setq *autosave-acdoc* (vla-get-activedocument (vlax-get-acad-object)) *autosave-count* 0 ) (defun autosave ( obj arg ) (if (and (zerop (rem (setq *autosave-count* (1+ *autosave-count*)) 20)) (= 1 (getvar 'dwgtitled)) ) (vla-save *autosave-acdoc*) ) (princ) ) (princ)
If you don't have experience with reactor-based programs, there is no 'command' to run the program, simply load the program and the Visual LISP Command Reactor will run in the background, monitoring for when a command has ended, is cancelled by the user, or has failed.
After every 20 commands (this number can of course be changed to suit your preferences) the reactor callback function will save the active drawing.
This is of course only a very simple draft of such a utility, the program could be enhanced to save a copy of the drawing to a different directory, or the same directory etc.
I hope this helps!
In answer to your questions, follow these steps carefully:
(findfile "acaddoc.lsp")
(load "autosave.lsp" "Unable to load Autosave program.") (princ)Where autosave.lsp is the name of the LISP file saved earlier.
When a drawing is opened (new or existing), AutoCAD will automatically search the working directory & all support file search paths (in the order listed in the 'Files' tab) for a file called 'acaddoc.lsp'; AutoCAD will then automatically load the first such file found into the current drawing session, hence evaluating all AutoLISP expressions contained in the file.
Of course, you could alternatively copy the reactor code directly into the acaddoc.lsp file, however, in my opinion it is more manageable to have each AutoLISP program as a separate file loaded from the acaddoc.lsp, as the files can easily be replaced should the program be updated at a later date.
Using the acaddoc.lsp in lieu of the Startup Suite (within the AppLoad command) also makes migration to other machines a breeze, since the acaddoc.lsp and any accompanying AutoLISP programs can simply be copied to a support file search path (SFSP) on the new machine, and the programs will automatically be loaded with no further configuration required.
Alternatively, if you want to ensure a program is available for all users on a network, rather than using the Startup Suite you can add a common network path accessible by all users as a SFSP on every user's system and save the acaddoc.lsp and any accompanying programs to this network path.
This way, you (as a CAD Manager perhaps) have complete control over which programs are loaded on your users' machines, and, should any program need to be updated in the future, you can modify the single file at the network location and the change will be reflected across all computers referencing the network path as a SFSP.
Of course, 'with power comes responsibility' since the inherent behaviour of the acaddoc.lsp opens the door should anyone choose to insert malicious code into this file. These dangers are described in my post on the 'Dangers of the acaddoc.lsp'.
I hope the above explanations are clear, if not just ask.
Lee
@Lee_Mac wrote:Timers are a pain to implement using reactors since the reactor would need to monitor the system clock at regular intervals, for example by monitoring a callback event which is likely to occur regularly.
To suggest an alternative, the following simple reactor-based code will save the current drawing after every 20 commands:
After every 20 commands (this number can of course be changed to suit your preferences) the reactor callback function will save the active drawing.
This is of course only a very simple draft of such a utility, the program could be enhanced to save a copy of the drawing to a different directory, or the same directory etc.
I hope this helps!
Command reactors fire when commands are started/ended by scripting (e.g., LISP's (command) function or its ObjectARX equivalent acedCommand(), etc.).
You can probably find thousands of LISP scripts in this discussion group's history that execute one or more AutoCAD commands repeatedly in a loop of some sort, hundreds or even thousands of times in the matter of a few seconds.
Perhaps you might want to re-think your proposed solution?