Lee Chu Chu Posted July 11, 2014 Posted July 11, 2014 Is there anyway to check to see if the user has inputted into the command line and using a lisp, to tell that as soon as the user has pressed esc to not only cancel the command but to also set quantities? Quote
Lee Mac Posted July 11, 2014 Posted July 11, 2014 You could perform the necessary operations within a locally defined *error* function - more info here. Quote
ur_naz Posted July 12, 2014 Posted July 12, 2014 put your look on vl-catch-all-apply, vl-catch-all-error-p, vl-catch-all-error-message functions. this functions help to avoid most of exceptions in your app. while *error* function is called then program is interrupted, vl-catch-all-apply can substitute try except finally construction used in other then autolisp languages Quote
Lee Chu Chu Posted July 14, 2014 Author Posted July 14, 2014 I am using vl-catch-all-apply but it doesnt seem to be doing what I want it to do. I keep pressing esc to cancel the command but it doesnt cancel the lisp reactor thats supposed to be called up when I cancel a command. Quote
Lee Chu Chu Posted July 14, 2014 Author Posted July 14, 2014 @Lee. I am trying to use a lisp reactor. So basically this lisp reactor lives in a lisp file with a lot of my general code. I want to call up this lisp reactor when a specific function is being used in the command line. So whilst this command is running, variables like layer and snap settings have been set but once the command is either cancelled or ended, I wanted to set it back to the original settings before I started the command. I only want this reactor to work once the command is being called up. This is the lisp reactor code I have been using. Acknowledgements to ronjonp for writing this code up on: http://www.theswamp.org/index.php?topic=16519.5;wap2 (if (not *rjp-lispReactors*) (setq *rjp-lispReactors* (vlr-lisp-reactor nil '((:vlr-lispWillStart . strtlsp) (:vlr-lispCancelled . cncllsp) ) ) ) (princ) ) (defun strtlsp (calling-reactor strtlspInfo / stlisp) (setq stlisp (strcase (nth 0 strtlspInfo) T) rjp-varlist nil rjp-varlist (mapcar '(lambda (x) (cons x (getvar x))) '("apbox" "aperture" "attdia" "attmode" "aunits" "autosnap" "blipmode" "cecolor" "celtscale" "clayer" "cmddia" "cmdecho" "dimassoc" "dragmode" "edgemode" "elevation" "expert" "fillmode" "gridmode" "gripsize" "highlight" "ltscale" "orthomode" "osmode" "osnapcoord" "plinewid" "snapang" "snapmode" "textsize" ) ) ) (princ "LISP START") ) (defun cncllsp (calling-reactor cncllspInfo /) (mapcar '(lambda (x) (vl-catch-all-apply 'setvar (list (car x) (cdr x)) ) ) rjp-varlist ) (princ "\n <<Lisp cancelled...>>") ) I see that the reactor does start since I see my printed message LISP START but whenever I press esc to cancel the function, the message lisp cancelled doesnt get printed out and the settings dont revert back to when it started. Anyway I can modify this code to specifically do that? I've also tried using command reactors but they are a bit dodgy to work with and it can only be used in the entirety of the lisp file since it is waiting for a command to be called up. So I have no idea what I should be doing, if I should even be using lisp-reactors or not. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.