Jump to content

Recommended Posts

Posted

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
   )

Posted

You can't use commands inside reactor callbacks. Use (vla-put-layeron ... :vlax-false).

Posted

Ah, that was it.

 

Thank you. :beer:

Posted

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.

Posted

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.
Posted
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).
Posted

Nice, thanks for that broncos.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...