reactors

cesi2d

Usenet Archive
Joined
Jul 16, 2003
Messages
27
Reaction score
0
Hello

I'm newbie for reactors usage in lisp programing.

I want to detect the usage of some Autocad commands (copy for example), but adding an object-reactor for many autocad object is persaps too expensive, so I'm prefering use an command-reactor . How can I know the list of entities by user selecteds ? I know finding the new entities but not the original object .

please help me.

regards

Luc Vallot
 
Bonjour Luc,
Your english is very good. Can you describe exactly what you want to do? I haven't tried this but you might use the vlr-command-reactor and track 2 events (:vlr-commandwillstart and :vlr-commandended) During the commandwillstart event you might check which command is beginning and if copy, then you might get the last entity as a mark. Then you might use the commandended event to collect the objects created by copy and process them.

My tendency would be to use the object reactor to track what happens to particular objects. I haven't noticed any delay in my work.

Regards,
Doug
 
I'm newbie for reactors usage in lisp programing.
I want to detect the usage of some Autocad commands (copy for example), but adding an object-reactor for many autocad object is persaps too expensive, so I'm prefering use an command-reactor . How can I know the list of entities by user selecteds ? I know finding the new entities but not the original object .

please help me.

regards

Luc Vallot

Voici un petit échantillon de la façon dont je le fais, espèrent qu'il aide, a l'amusement.

Here is a little sample of how I do it, hope it helps, have fun.

Luis.

---sample code starts here---

(defun no
;; do not proceed if any of the following commands where invoked (not (wcmatch (getvar "cmdnames") "UNDO,U,REDO,OOPS")))

(defun acdb-objectappended (reactor params)
(if (and (no)
;; grab only ename's
;; revise this line to sort other type of objects
(eq (type (cadr params)) 'ename)
;; in case you need to sort ceartain type
;; they can be catched here
;;; (= (cdadr (entget (cadr params))) "DIMENSION")
;; the ename is not part of our list yet?
(not (vl-position (cadr params) sel_lst)))
;; make the list
(setq sel_lst (cons (cadr params) sel_lst))))

(defun editor-commandended (reactor params)
;; make sure we did the selection and was part of the copy command (if (and (no) sel_lst (eq (car params) "COPY")) (progn ;; here we have all the object selected (if (not (vl-catch-all-error-p (setq previous_sel (vl-catch-all-apply 'vla-get-activeselectionset (list (vla-get-activedocument (vlax-get-acad-object))))))) (vlax-for obj previous_sel (vla-highlight obj :vlax-true))) (vla-clear previous_sel) (setq previous_sel nil) ;; turn the list nil here - a must (setq sel_lst nil)))
(setq sel_lst nil))

;; make sure we load our reactor once
(or acdb_reactor
(setq acdb_reactor
(vlr-acdb-reactor
"acdb reactor"
;; using only the object appended event
;; you can include also more events here to manipulate all if necessary ' ((:vlr-objectappended . acdb-objectappended)))))

;; same as above
(or editor_reactor
(setq editor_reactor
(vlr-editor-reactor
"editor reactor"
;; we might need to check the other events here
;; but since this is just a little sample...
'
((:vlr-commandended . editor-commandended)))))

(princ)

---sample code ends here---
 
Hello

If I understand Doug and Luis answers ,

I must use object reactors to find each original object been copied and save his ename inside a global list , AND two command-reactor , one for save the (entlast) at the command start , one to detect the end of command , collect the new object list and process them.

Thanks for your help

Luc
 
If you use vlr-object-reactor to track certain copied event of selected objects, then you would only need the commandended reactor to do whatever you want to the copies.

If you want to track copies of all the objects, you could use only the command reactor, then you would need both willstart and ended reactors (I think that would work).

If you want to work with any new object to categorize or layer it, you could use the acdb reactor, objectappended and the command reactor,commandended.

Hope that explains it better. There are certain situations where the commandended reactor may not fire until the next command.
 
(defun editor-commandended (reactor params)
;; make sure we did the selection and was part of the copy command (if (and (no) sel_lst (eq (car params) "COPY"))

Luc,

In my sample code you have already the list with the copied objects too is this one: SEL_LST, make sure is made by ename's ONLY.

And also you have the collection of the previous selected object too:
PREVIOUS_SEL

From there it will be an easy job...

Luis.
 
Doug and Luis,

Thanks for your help, I can work now !

Have a good day

Luc
 

Latest threads

Back
Top