PDA

View Full Version : Help Please...Problem With Reactor


vferrara
2009-04-10, 08:30 PM
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.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;
;;;;;;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

RobertB
2009-04-14, 09:31 PM
Well, you are filtering for commands that match *image*. So in 2009, what is the command that is really being executed?

vferrara
2009-04-15, 06:52 PM
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

RobertB
2009-04-17, 12:47 AM
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.