Results 1 to 6 of 6

Thread: Reactors???

  1. #1
    Member
    Join Date
    2009-12
    Posts
    21
    Login to Give a bone
    0

    Default Reactors???

    Does anyone know of a way to determine when a footprint is being laid down in an Autocad Electrical drawing.

    I understand there are reactors in lisp and I am wondering whether this (or something else) is a suitable mechanism to determine when a particular symbol is being placed?

    Thanks

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

    Default Re: Reactors???

    I do not use AutoCAD Electrical, but I would imagine that there's both a specific Command to place a 'footprint', and also a specific Entity/Object being created or modified... You might try looking into using a Command Reactor or an AcDb Reactor.

    HTH
    "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

  3. #3
    Member
    Join Date
    2009-12
    Posts
    21
    Login to Give a bone
    0

    Default Re: Reactors???

    Quote Originally Posted by RenderMan View Post
    I do not use AutoCAD Electrical, but I would imagine that there's both a specific Command to place a 'footprint', and also a specific Entity/Object being created or modified... You might try looking into using a Command Reactor or an AcDb Reactor.

    HTH
    Hi Renderman

    I've looked at these two reactors unfortunately without luck

    It seems that Autocad Electrical is perhaps hiding something???? When I used CommandWillStart all I got was a lot of calls to UNDO command with a few intermingled commands in between but nothing that indicated a insert or anything related. The AcDB reator yielded nothing for any of the reactor events.

    thanks anyway. Nice thought but as usual with Autocad, especially Electrical, so much seems hidden away.....

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

    Default Re: Reactors???

    Perhaps you can post a sample drawing with the code you used to test... If I cannot help you (as I do not have Electrical), hopefully someone who does, can.
    "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

  5. #5
    Member
    Join Date
    2009-12
    Posts
    21
    Login to Give a bone
    0

    Default Re: Reactors???

    I've been playing around and have managed to get something from the command reactors working using this code:

    Code:
    (vl-load-com)
    
    (vlr-command-reactor "Test Reactor" '((:vlr-commandWillStart . testReactor)))
    
    (defun testReactor (calling-reactor commandInfo / ) 
    (alert (car commandInfo)) 
    )
    Although this is AutoCAD Electrical, the insert command is the last command after all of the menus which are provided for the insert footprint function, before the block is inserted. I believe this is a good thing (maybe) as this removes the 'electrical' side and makes this a straightforward AutoCAD issue.

    I believe my code functions on any AutoCAD drawing when a block is inserted.

    My thought process is this:
    1) determine when a block is inserted
    2) ensure the block has the one attribute I am looking for
    3) if it has the required attribute then call function
    4) if it does not have the required attribute, continue.

    So, I can determine when an insert command occurs, now I need to know is how to interrogate the inserted block!!

    Can anyone help with this?

    Many thanks

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

    Default Re: Reactors???

    FWIW -

    Command reactor(s) are great, but I really think you need to look into an AcDb Reactor instead, given that you want to test the Object(s) being added for a specific component... It's far easier to do this with an AcDb Reactor (at the time the Object is added to the Database), than to iterate a selection set of all like Objects post-CommandCancelled/Ended/Failed Event. Just a thought.

    Separately, when using Reactors, I always make a habit of incorporating a check of some kind in order to prevent duplicate Reactors, as they can cause many problems. I also prefer to send feedback to the command line, rather than to an alert dialog, and include a 'stop' command (personal preference):

    Code:
    (vl-load-com)
    
    (defun c:StartReactor ()
      (or *Reactor_Command*                                                 ; If already defined, skip
          (setq *Reactor_Command*                                           ; Define new reactor
                 (vlr-command-reactor
                   "My command reactor "
                   '((:vlr-commandWillStart . Callback:CommandWillStart))
                 )
          )
      )
      (prompt "\n  >>  Command reactor loaded ")
      (princ)
    )
    
    (defun Callback:CommandWillStart (rea cmd)
      (princ "\n  Callback:CommandWillStart  >>  ")
      (princ (car cmd))
      (terpri)
    )
    
    (defun c:StopReactor ()
      (if *Reactor_Command*
        (progn
          (vlr-remove *Reactor_Command*)
          (setq *Reactor_Command* nil)
        )
      )
      (prompt "\n  >>  Command reactor stopped ")
      (princ)
    )
    "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

Similar Threads

  1. Can someone help me with reactors?
    By ReachAndre in forum AutoLISP
    Replies: 5
    Last Post: 2014-05-28, 03:02 PM
  2. need some help with reactors
    By darren_lambett in forum AutoLISP
    Replies: 1
    Last Post: 2009-04-20, 12:31 PM
  3. Reactors????
    By LLAW3224 in forum AutoLISP
    Replies: 2
    Last Post: 2005-03-04, 12:44 PM
  4. Can this be done with reactors?
    By kieren in forum AutoLISP
    Replies: 5
    Last Post: 2004-10-06, 03:43 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
  •