Hello
I just started learning LISP yesterday, as our office needs an autosave LISP. Please do not ask me why, people have requested it and I have to do it...
How I wanted to do it:
The LISP will be loaded on every PC of every person with AutoCAD.
On startup "command_count" will be on 0
When using a command like plinie this happens: (+ 1 command_count)
Commands like zoom, undo etc will be ignored
When command_count reaches 20 it executes the qsave command
If using the qsave command it resets the command_count to 0
Thats my not working LISP atm:
(defun c:losave () (setq command_count 0) (+ 1 command_count) (if command_count 10 "_qsave") ) ;(if command "_qsave" setq 0) ;(if command "_zoom" (- 2 command_count)) ;(if command "_undo" (- 2 command_count)) ;(if command "_qsave" (* 0 command_count)) ;(setq command_count (+ 1 command_count))
Hope any one can help me
Thanks a lot
Josh
Solved! Go to Solution.
Solved by dbroad. Go to Solution.
First: Really, really bad idea. Taking the decision of whether or not to save and when to save out of the drafter's hands is foolish to say the least. At least use the save command, not qsave. Then you'll have hope of getting the original file back at the end of a series of 80 bad commands.
That said, if you still want to proceed, you could use a command reactor that triggers on a :vlr-commandended event.
Try to explain to the administrators why savetime and AutoCAD's built-in saving and drawing recovery is a better plan.
Agreed. I use a reactor to monitor the save event (catches both user saves as well as system auto-saves), which creates an indexed copy in the users AutoCAD temp folder. It also does some time/count management so they only keep a couple of days or a dozen or so copies, just to keep things under control. Now that we have a dependable Shadowcopy system running on the servers, I might tighten up the controls a bit more.
Good Morning
Thanks for your replys
Many people here simply forget to save theyre drawing. And lets be honest the backup function of AutoCAD is terrible!
Thats why I something, what "helps" the others to save theyre stuff.
Sorry I'm new to LISP, what is :vlr-commandended?
Thanks for your help!
Kind Regards
Josh
This code should help teach you about reactors. What you posted could be the basis for a callback function.
(if (null mySaveReactor)(progn (setq reactorCallbacks '((:vlr-commandended . vlr-trace-reaction))) (setq mySaveReactor (vlr-command-reactor reactorData reactorCallbacks)) )) ;;Save all work before loading this. Keeping your trace window open may lock system up.
;;Load this and keep your vlide window open with the trace window displayed. ;;As each command ends, watch your trace window. After you understand what is ;;happening, create your own substitute callback to replace vlr-trace-reaction. ;;Read up on reactors in your help documents and on other posts in the newsgroups.
I repeat my warning. Autoqsaves are not good solutions to what is a CAD training issue. A better option would be to provide a message pop-up after 20 commands saying. "Don't you want to save yet? You lose your work, you redo it for free."
Thanks for your effort, but I didnt understand anything when I used that code...
VisualLISP opend and my command list got spammed by unknown commands....
Would it be the bether solution if I would write something, which creates a backup like every 15min to a certain directory on our server?
Kind Regards
Josh
@LombUser wrote:....
Would it be the bether solution if I would write something, which creates a backup like every 15min to a certain directory on our server?
....
No need to write something -- AutoCAD will do that for you. Options / Open and Save tab / File Safety Precautions area / Automatic Save and Create backup copy with each save options; also Files tab / Automatic Save File Location item. [Navigation and headings may vary with release].
I know AutoCAD is supposed to do that, but we had many occasions, where the tick for that would be gone!
Even if the tick is there, it doesnt create backups, as it should! One guy at our office lost his whole work of a day, as AutoCAD didnt do the backup!
We also use BaCad and I think thats the source of our problem, but we arent allowed to remove it, sadly.
Thats the only reason we are looking for a LISP which would do that.
Kind Regards
Josh
dbroad you are a true genius!
Thanks a lot, with your little guide! I'll try that properly as soon as possible.
I guess my problems are solved for now 🙂
Cheers
Josh
If this thread solved your problem, be sure to mark the post that solved it as a solution.
If you've got users who aren't reliable then there are ways to make autocad more reliable regardless of their shortcomings.
As for autosaves, add the following to your acaddoc.lsp. This way even if autocad loses the setting in a crash, it will be reset the next time a drawing is opened.
(setvar "SAVETIME" 10)