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

COMMAND TO CONTROL WHEN LISP LISP is CANCELLED

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
marcelogarcia3251
797 Views, 3 Replies

COMMAND TO CONTROL WHEN LISP LISP is CANCELLED

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.

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: marcelogarcia3251

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

EESignature

Message 3 of 4
mpalan2009
in reply to: hmsilva

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

Message 4 of 4
marcelogarcia3251
in reply to: hmsilva

Thank you, very nice home to Lee Mac's

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

Post to forums  

Autodesk Design & Make Report

”Boost