PDuMont Posted August 1, 2016 Posted August 1, 2016 Hello, I hope all is well. I am trying to modify a reactor for a user who wants the viewport layer to turn off when a dimension command is active. The code I inserted works by itself but does not work within the reactor. Any ideas? (foreach itm comLst (if (member (car args) itm) (progn (if (not (tblsearch "LAYER" (caar itm))) (progn (setq nLay (vla-Add (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ end of vla-get-ActiveDocument ) ;_ end of vla-get-Layers (caar itm) ) ;_ end of vla-Add ) ;_ end of setq (vla-put-Color nLay (cadar itm)) (setq com:resFlg T) ) ; end progn ) ; end if (setq com:oldLay (getvar "CLAYER") com:resFlg T ) ;_ end of setq (setvar "CLAYER" (caar itm)) [color="red"](if (= "DIM" (getvar 'clayer)) (vl-cmdf "-layer" "off" "XVIEW" "" "") )[/color] ;_ end of if ) ; end progn ) ; end if ) Quote
Roy_043 Posted August 1, 2016 Posted August 1, 2016 You can't use commands inside reactor callbacks. Use (vla-put-layeron ... :vlax-false). Quote
broncos15 Posted August 2, 2016 Posted August 2, 2016 For future reference, you can also use vla-sendcommand if you need to use a command specifically in the reactor. The vla-sendcommand sends a command string to autocad. Quote
PDuMont Posted August 2, 2016 Author Posted August 2, 2016 Thank you for that Broncos, I was unfamiliar with that. Would you have any reason why the AfraLisp website would report this: You should never use this method to issue a command for which there is an ActiveX method available. For example, do not use SendCommand "VBALOAD ". Instead, use the LoadDVB method. Quote
broncos15 Posted August 2, 2016 Posted August 2, 2016 Thank you for that Broncos, I was unfamiliar with that. Would you have any reason why the AfraLisp website would report this: I am not 100% sure on the why. One reason that comes to mind though is that vla-sendcommand sends stuff to the command line, which could slow down the LISP routine if is used frequently throughout it. If you want to see an example of a reactor that makes use of it, go to http://www.cadtutor.net/forum/showthread.php?93661-Lisp-for-fillet-radius./page2 for the fillet reactor and offset reactors (they both are very handy and BigAL's finalized one on page 3 is really cool). 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.