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

Undo Function

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
C.Utzinger
805 Views, 2 Replies

Undo Function

HI

 

I just started to use the undo command to turn back in one step the Routine.

 

But how can I after cancelling the Routine in the middle, turn back in one step.

 

Or how can i include the "command undo end" in the erros message?

 

Please help...

 

(defun C:<T-1-50-2mm( / *error* lay cmd)

	(defun *error* (errmsg)
    	   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      	   (princ (strcat "\nError: " errmsg)))
    	   (setvar 'CLAYER lay)
    	   (setvar 'CMDECHO cmd)
    	   (princ))

	(command "_.undo" "_begin")
	
(setq lay (getvar 'CLAYER) cmd (getvar 'CMDECHO)) (setvar 'CMDECHO 0)
(command "_.-LAYER" "_m" "-I-Text_020" "_co" "2" "-I-Text_020" "") (command "_.style" "simplex7-10" "simplex.shx" "10" "0.7" "0" "_n" "_n" "_n") (command "_.mtext") (princ "\nMtext: erste Fensterecke angeben: ") (command pause) (princ "\nMtext: zweite Fenstrecke angeben: ") (command pause "") (command "_mtedit" "l") (setvar 'CLAYER lay) (setvar 'CMDECHO cmd)
(command "_.undo" "_end")
(prin1) ) ; end of defun
2 REPLIES 2
Message 2 of 3
C.Utzinger
in reply to: C.Utzinger

Ok this way it works, with command-s!!!

 

(defun C:<T-1-50-2mm( / *error* lay cmd)

	(defun *error* (errmsg)
    	   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      	   (princ (strcat "\nError: " errmsg)))
    	   (setvar 'CLAYER lay)
    	   (setvar 'CMDECHO cmd)
	   (command-s "_.undo" "_end")
    	   (princ))

	(command "_.undo" "_begin")
(setq lay (getvar 'CLAYER) cmd (getvar 'CMDECHO)) (setvar 'CMDECHO 0) (command "_.-LAYER" "_m" "-I-Text_020" "_co" "2" "-I-Text_020" "") (command "_.style" "simplex7-10" "simplex.shx" "10" "0.7" "0" "_n" "_n" "_n") (command "_.mtext") (princ "\nMtext: erste Fensterecke angeben: ") (command pause) (princ "\nMtext: zweite Fenstrecke angeben: ") (command pause "") (command "_mtedit" "l") (setvar 'CLAYER lay) (setvar 'CMDECHO cmd)
(command "_.undo" "_end") (prin1) ) ; end of defun
Message 3 of 3
Kent1Cooper
in reply to: C.Utzinger

You can include an Undo End command in the *error* handler, but how you do it depends on what version you're using.  In older versions it can be just as you have it at the end of the routine.  In newer versions that don't like (command) functions in *error*, you can use (command-s) instead, but that won't be recognized in older versions.  For use in any version, you can do it with (vla-) functions -- Search this Forum for startundomark and endundomark for examples.

 

You can also include (command "_.u") or (command-s "_.u") in the *error* handler.  I'm not aware of a (vla-) way to do that, but there may be one.

Kent Cooper, AIA

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

Post to forums  

Forma Design Contest


AutoCAD Beta