Help: Reactors Action when select a block with attributes

Help: Reactors Action when select a block with attributes

Luís Augusto
Advocate Advocate
917 Views
2 Replies
Message 1 of 3

Help: Reactors Action when select a block with attributes

Luís Augusto
Advocate
Advocate

Hello guys.
Could you give me an example of reactors?
I would like was performed an action, when select a block with attributes. (Only click)
The event should be triggered if the selection contains only a single object.
Thank you in advance.
Best regards, Luís Augusto.

0 Likes
Accepted solutions (1)
918 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

As a starting point....

 

Spoiler
(defun c:BlockSelect_UnLoad ()
  (if *BlockSelect_miscellaneousReactor*
    (vlr-remove *BlockSelect_miscellaneousReactor*))
  (princ)
)

(defun BlockSelect_OnLoad ()

  (if *BlockSelect_miscellaneousReactor*
    (vlr-remove *BlockSelect_miscellaneousReactor*))

  (setq *BlockSelect_miscellaneousReactor* (vlr-miscellaneous-reactor
					     nil
					     '((:vlr-pickfirstmodified . BlockSelect_CallBack))))
  (princ "\nBlockSelect is running ")
  (princ)
)

(defun BlockSelect_CallBack (rea lst / ss obj i)

  (if (and (setq ss (cadr (ssgetfirst)))
	   (= 1 (sslength ss))
	   (= "INSERT" (cdr (assoc 0 (entget (ssname ss 0)))))
	   (= 1 (cdr (assoc 66 (entget (ssname ss 0)))))
	   )
    (princ "\n *** Single block with att selected ***"))
  (princ)
)


(BlockSelect_OnLoad) ; Starts the reactors.
Message 3 of 3

Luís Augusto
Advocate
Advocate

BeekeeCZ, exactly what I needed to start.
Sorry request help without starting code, I was not able to understand the reactors. This issue seemed a bit confused.
But now I understood the code you wrote, using the debugger Vlide.
Thank you so much for the great help. Smiley Very Happy
I believe you demystified this issue for me.
It may be precipitated, but I now believe that I am able to understand the mechanisms of the reactors.

I am very grateful for your help. I know you use your time to help me.

 

Best regards, Luís Augusto.