Undo Function

Undo Function

C.Utzinger
Collaborator Collaborator
979 Views
2 Replies
Message 1 of 3

Undo Function

C.Utzinger
Collaborator
Collaborator

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
0 Likes
Accepted solutions (1)
980 Views
2 Replies
Replies (2)
Message 2 of 3

C.Utzinger
Collaborator
Collaborator
Accepted solution

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
0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant

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