nataca 发表于 2022-7-6 08:16:58

Help me Example Reactor- Visua

I'm learning Reactor. I want to use reactor for ATT Block.
In found in help: vlr-object-reactor -> :vlr-subObjModified
but don't have any Example about :vlr-subObjModified
Thanks.

Lee Mac 发表于 2022-7-6 08:53:02

Example:
 

(defun c:Start_Object_Reactor nil (if (not (vl-position "ATT-REACT"            (mapcar            (function                (lambda (x)                  (strcase                  (vlr-data x))))            (cdar (vlr-reactors :vlr-object-reactor)))))   (if (and (princ "\n Select Objects to Trigger Reactor: ")            (setq i -1 ss (ssget '((0 . "INSERT") (66 . 1)))))   (progn       (while (setq ent (ssname ss (setq i (1+ i))))         (setq OwnerList (cons (vlax-ename->vla-object ent) OwnerList)))          (vlr-object-reactor OwnerList "Att-React"         (list         (cons :vlr-subobjmodified 'DoIt)))))   (princ "\n** Object Reactor Already Running **")) (princ))(defun DoIt (Object Reactor Args) (alert   (strcat "You Modified an Attribute in Block: "         (vl-prin1-to-string Object))) (princ))(defun c:End_Object_Reactor (/ React) (if (and (setq React            (vl-some            (function                (lambda (x)                  (if (eq "ATT-REACT"                        (strcase (vlr-data x))) x)))            (cdar (vlr-reactors :vlr-object-reactor))))          (vlr-added-p React))   (vlr-remove React)   (princ "\n** Reactor Not Running **")) (princ))      

nataca 发表于 2022-7-6 09:15:01

thanks Lee.
I have 2 attriblock.
attriblock1 have: Tag1 ->string1
attriblock2 have: Tag2 ->string2
 
I want always string1 = string2.
 
Help me code in function "DO IT"
vlr-object-reactor OwnerList "Att-React"
          (list
            (cons :vlr-subobjmodified 'DoIt)))))

RobyG 发表于 2022-7-6 09:21:06

Hi Lee,
 
This is about what I need, but why does the alert fire once for each attribute in the block when I only change one or none and then use ok ?
If canceled it does not fire the alert.
 
my code in the Doit part only needs to happen once each time the block is accessed and modified.
 
Thanks
 
roby
页: [1]
查看完整版本: Help me Example Reactor- Visua