Results 1 to 6 of 6

Thread: Reactor advice please

  1. #1
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Reactor advice please

    Disclaimer: I am asking before I even try, so be nice.

    I have this code to make sure MLeader, QLeader, and Leader are on the Dimensions layer.
    Code:
    ;;;
    ;;; Leaders on "Dimensions" layer reactor
    ;;;
    
    (IF (NOT |leader_reactor|)
      (SETQ	|leader_reactor|
    	 (VLR-COMMAND-REACTOR
    	   nil
    	   '((:VLR-COMMANDWILLSTART . startleadercommand)
    	     (:VLR-COMMANDENDED . endleadercommand)
    	     (:VLR-COMMANDCANCELLED . cancelleadercommand)
    	    )
    	 ) ;_ end of VLR-COMMAND-REACTOR
      ) ;_ end of SETQ
    ) ;_ end of IF
    
    (DEFUN startleadercommand
    			  (calling-reactor startcommandinfo / |commandstart|)
      (SETQ |leader_clayer| (GETVAR "clayer"))
      (SETQ |commandstart| (CAR startcommandinfo))
      (IF (OR (= |commandstart| "LEADER")
    	  (= |commandstart| "MLEADER")
    	  (= |commandstart| "QLEADER")
          ) ;_ end of OR
          (SETVAR "clayer" "DIMENSIONS")
      ) ;_ end of IF
      (PRINC)
    ) ;_ end of DEFUN
    
    (DEFUN endleadercommand	(calling-reactor endcommandinfo / |commandend|)
      (SETQ |commandend| (CAR endcommandinfo))
      (IF (OR (= |commandend| "LEADER")
    	  (= |commandend| "MLEADER")
    	  (= |commandend| "QLEADER")
          ) ;_ end of OR
        (SETVAR "clayer" |leader_clayer|)
      ) ;_ end of IF
      (PRINC)
    ) ;_ end of DEFUN
    
    (DEFUN cancelleadercommand
    			   (calling-reactor cancelcommandinfo / |commandcancel|)
      (SETQ |commandcancel| (CAR cancelcommandinfo))
      (IF (OR (= |commandcancel| "LEADER")
    	  (= |commandcancel| "MLEADER")
    	  (= |commandcancel| "QLEADER")
          ) ;_ end of OR
        (SETVAR "clayer" |leader_clayer|)
      ) ;_ end of IF
      (PRINC)
    ) ;_ end of DEFUN
    I would like to make another one for XLines.

    1. Can I have multiple reactors defined?
    2. Will a reactor still work to force the XLine on a specific layer if the command is called from inside a LISP? I have a LISP that does XLH and XLV. And another one that puts an H and a V at 0,0.

    So please, if you would, just drop some help, advice, or insight on reactors and making them play pretty.

    Thanks,
    MC

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Reactor advice please

    Why not change those IF functions to COND functions to cycle through the possible different commands? Also, if you can probably combine the end and cancelled reactor functions to the same if you are doing the same steps.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,665
    Login to Give a bone
    0

    Default Re: Reactor advice please

    Lee Mac's Command Reactor code to automatically set the current layer when a command is called, proceeding to reset to the previous current layer when the command is completed should be just what you're looking for: http://www.lee-mac.com/layerdirector.html

    It will even add the layers, descriptions and properties as needed and comes with commands to turn it off and on.

  4. #4
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Reactor advice please

    Sorry I'm just now getting back to this. We just went through 4 months of 50+ hour weeks and I had zero time.

    I was under the impression that the start, end, and cancel had to all be separate definitions. Can they be combined?

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Reactor advice please

    Quote Originally Posted by madcadder View Post
    I was under the impression that the start, end, and cancel had to all be separate definitions. Can they be combined?
    Each Event's handler is defined by you (in the list of grouped pairs provided to VLR-COMMAND-REACTOR), so you can tell each which Defun to use.

    I typically use one for CommandStarted, and another for CommanCancelled, CommanEnded and CommanFailed.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Reactor advice please

    So for safety and completeness I should really add a command failed.

Similar Threads

  1. vlr-dwg-reactor issue MY FIRST REACTOR
    By treaves04413213 in forum AutoLISP
    Replies: 21
    Last Post: 2013-10-18, 12:36 PM
  2. Replies: 1
    Last Post: 2009-08-14, 01:05 PM
  3. Help Please...Problem With Reactor
    By CADdancer in forum AutoLISP
    Replies: 3
    Last Post: 2009-04-16, 10:47 PM
  4. Replies: 1
    Last Post: 2008-11-04, 05:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •