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