HELLO, I HAVE THE FOLLOWING LISP
DEFUN c:DLI ()
(setq MLAYER (GETVAR "CLAYER"))
(SETVAR "CLAYER" "COTAS M")
(COMMAND "DIMLINEAR" PAUSE PAUSE PAUSE)
(SETVAR "CLAYER" MLAYER)
(prompt "comandos carregados com sucesso")
(princ)
)
When I call this routine it works correctly, but when I call and tightening ESC canceling the routine she did not back the current layer configuration.
Is to make the routine when canceled, return the current settings?
Thank you.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Hi Marcelo,
one way:
(defun c:dli (/ *error* MLAYER) (defun *error* (msg) (if MLAYER (SETVAR "CLAYER" MLAYER)) (cond ((not msg)) ((member msg '("Function cancelled" "quit / exit abort"))) ((princ (strcat "\n** Error: " msg " ** "))) ) (princ) ) (setq MLAYER (GETVAR "CLAYER")) (SETVAR "CLAYER" "COTAS M") (COMMAND "DIMLINEAR" PAUSE PAUSE PAUSE) (prompt "comandos carregados com sucesso") (*error* nil) (princ) )
take a look at Lee Mac's Error Handling
Henrique
Another way that I have done this in the past is to put a mark in the database. If my lisp function called a bunch of commands then the error function would undo back to the mark. You could also group the functions or commands togather so that 1 undo will undo the whole group of commands at the same time.
Hope this helps.
Matthew