Search the Community
Showing results for tags 'command reactor'.
Found 1 result
So I want to be able to set things inside functions when the command is called up in the command line. I tried using a command reactor. It works fine when it is outside of the function that I wanted for it to be activated but when I put it inside the function, it doesnt seem to be getting the values of the variables before the command is called up. so I have a simple function used for texting. (defun c:trec() (reactoron) (command "rectang") ) This is not the actual function I want to use in autocad but using this as my test. So this is my reactor which lives in reactoron. (defun reactoron() (vl-load-com) (vlr-command-reactor nil '((:vlr-commandWillStart . startCommand))) (vlr-command-reactor nil '((:vlr-commandEnded . endCommand))) (vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand))) (defun startCommand (calling-reactor startcommandInfo / thecommandstart) (setq OldLayer (getvar "CLAYER")) (setq thecommandstart (nth 0 startcommandInfo)) (cond ((= thecommandstart "TREC") (setvar "CLAYER" "4")) ) (princ) ) (defun endCommand (calling-reactor endcommandInfo / thecommandend) (setq thecommandend (nth 0 endcommandInfo)) (cond ((= thecommandend "TREC") (setvar "CLAYER" OldLayer)) ) (vlr-remove-all) (princ) ) (defun cancelCommand (calling-reactor cancelcommandInfo / thecommandcancel) (setq thecommandcancel (nth 0 cancelcommandInfo)) (cond ((= thecommandcancel "TREC") (setvar "CLAYER" OldLayer)) ) (vlr-remove-all) (princ) ) ) I should thank afralisp for the code sample which this code here is based from. So someone help me find a way to be able to activate this command reactor inside my function TREC?