Results 1 to 4 of 4

Thread: Help Please...Problem With Reactor

  1. #1
    I could stop if I wanted to
    Join Date
    2015-09
    Posts
    420
    Login to Give a bone
    0

    Default Help Please...Problem With Reactor

    Hello Augi Members,

    I had developed a reactor to automatically set a specific layer when attaching an image file to the drawing. When we migrated to AutoCAD 2009 this image reactor stopper working. Can anyone take a look at the enclosed code and let me know if you find anything that would cause this to happen.

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;
    ;;;;;;IMAGE REACTOR
    ;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;
    (vl-load-com)
    
    (or dimagereactor
        (setq dimagereactor
               (vlr-command-reactor
                 nil
                 '((:vlr-commandwillstart . cmdstart)
                   (:vlr-commandended . cmdend)
                   (:vlr-commandfailed . cmdend)
                   (:vlr-commandcancelled . cmdend)
                   )
                 ) ;_ end of vlr-command-reactor
              ) ;_ end of setq
        ) ;_ end of or
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;
    ;;;;;;START REACTOR
    ;;;;;;
    (defun cmdstart (react cmd / lay)
     (setq cmd (strcase (car cmd) t))
      (cond
        ((wcmatch cmd "*image*")
           (setq *clayer* (vla-get-activelayer
                          (vla-get-activedocument (vlax-get-acad-object))
                          ) ;_ end of vla-get-ActiveLayer
               lay      (vla-add
                          (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
                          "S-image"
                          ) ;_ end of vla-add
               ) ;_ end of setq
    ;;;;;;
    ;;;;;;Check for Defpoints Layer
    ;;;;;;
         (if (= (strcase (vla-get-name *clayer*)) "DEFPOINTS")
           (alert "...The Current Layer is \"DEFPOINTS\" ...Do Not Attach Image Files in Layer Defpoints...Setting Layer S-image As Active Layer...")
           ) ;_ end of if
    
         (vla-put-color lay 9)
         (vla-put-activelayer
           (vla-get-activedocument (vlax-get-acad-object))
           lay
           ) ;_ end of vla-put-ActiveLayer
         )
        ) ;_ end of cond
    
      ) ;_ end of defun
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;
    ;;;;;;END REACTOR
    ;;;;;;
    (defun cmdend (react cmd /)
      (setq cmd (strcase (car cmd) t))
      (cond
        ((wcmatch cmd "*image*")
         (if *clayer*
           (vla-put-activelayer
             (vla-get-activedocument (vlax-get-acad-object))
             *clayer*
             ) ;_ end of vla-put-ActiveLayer
           ) ;_ end of if
         (setq *clayer* nil)
         )
        ) ;_ end of cond
     
      ) ;_ end of defun
    Any assistance would be appreciated....!

    Regards,
    Vince

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Help Please...Problem With Reactor

    Well, you are filtering for commands that match *image*. So in 2009, what is the command that is really being executed?
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  3. #3
    I could stop if I wanted to
    Join Date
    2015-09
    Posts
    420
    Login to Give a bone
    0

    Default Re: Help Please...Problem With Reactor

    Hi Robert,

    Thank you for your response.....!

    In 2009 the actual command is "ExternamReferences" which will allow us to attach "dwgs", "dwfs", "dgns" and "images". However, I have similar reactors for "dwg" files and "dwf" files etc. so my question is......How can I filter further down to get to where the user specifies whether he is attaching a "dwg", "dwf", "dgn" or "image" (and "pdf" in 2010) file so the appropriate reactor can set the proper layers....??

    I do not know how to set this up. Can I impose upon you for aome assistance....??

    Any help would be appreciated.

    Regards,
    Vince

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Help Please...Problem With Reactor

    What I would suggest is to record the last object in the current space when the command starts, and then at the end of command, check to see if the objects are different. If so, objects have been added. Work your way back to the original last object, checking for images and fixing as required.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

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. Deepclone Reactor Problem
    By mr_nick in forum AutoLISP
    Replies: 4
    Last Post: 2012-04-30, 09:39 AM
  3. Replies: 1
    Last Post: 2009-08-14, 01:05 PM
  4. Problem in Reactor
    By rajat_bapi_mallick in forum AutoLISP
    Replies: 8
    Last Post: 2006-01-12, 11:33 PM
  5. Possible reactor problem?
    By Coolmo in forum AutoCAD General
    Replies: 2
    Last Post: 2004-10-25, 01:41 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
  •