Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autosave after 20 commands except zoom, undo

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
LombUser
885 Views, 11 Replies

Autosave after 20 commands except zoom, undo

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

 

11 REPLIES 11
Message 2 of 12
dbroad
in reply to: LombUser

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.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 12
dgorsman
in reply to: dbroad

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 12
LombUser
in reply to: dgorsman

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

Message 5 of 12
dbroad
in reply to: LombUser

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."

Architect, Registered NC, VA, SC, & GA.
Message 6 of 12
LombUser
in reply to: dbroad

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

Message 7 of 12
Kent1Cooper
in reply to: LombUser


@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].

Kent Cooper, AIA
Message 8 of 12
LombUser
in reply to: Kent1Cooper

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

Message 9 of 12
dbroad
in reply to: LombUser

2012-12-19_1028Reactor
Architect, Registered NC, VA, SC, & GA.
Message 10 of 12
LombUser
in reply to: dbroad

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

Message 11 of 12
dbroad
in reply to: LombUser

If this thread solved your problem, be sure to mark the post that solved it as a solution.

Architect, Registered NC, VA, SC, & GA.
Message 12 of 12
David.Pullin
in reply to: LombUser

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)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost