The Command Reactors doen't work in PROPERTIES command!?

The Command Reactors doen't work in PROPERTIES command!?

_Bilal
Advocate Advocate
744 Views
5 Replies
Message 1 of 6

The Command Reactors doen't work in PROPERTIES command!?

_Bilal
Advocate
Advocate

Greetings,

In the PROPERTIES command, when changing X or Y values of the selected object from the Properties palette
the object reactor is working fine while the Command reactor doesn't work, it seems the command ended
after the Properties palette is opened, so the commandended reactor failed to fire the callbacks, because
no command is running! 


I don't know if there is something that I missed here, however, Your help will be appreciated.


For testing purpose, I prepared a sample AutoLISP routine to track the user's modification of the LWPOLYLINE
vertex, XData has been added to the lwpolyline to count how many time the vertex has been changed by the user.
The sample code works fine in "STRETCH" "GRIP_STRETCH" "MOVE" commands while failed in the PROPERTIES command ------------(disregard the case of "COPY" "U" "UNDO" ......)----------------

 

 

(vl-load-com)
;Disable all object and command reactors with '"LWVertex" data
(foreach obj (apply 'append (mapcar 'cdr (vlr-reactors :vlr-object-reactor :vlr-command-reactor)))
	(if (= "LWV-Reactor" (car (vlr-data obj))) (vlr-remove obj))
)

;Make an LWPOLYLINE with XDATA
(regapp "XDlwvertex")
(setq obj
	(vlax-ename->vla-object
		(entmakex
			'(	(0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline")
				(90 . 2) (10 0.0 0.0) (10 100.0 100.0) (-3 ("XDlwvertex" (1070 . 0)))
			)
		)
	)
)
;Add object reactor to the new entity
(vlr-object-reactor
	(list obj) ;owner
	(list "LWV-Reactor" (vlax-get obj 'Coordinates)) ;Data=Identifier + Original LW vertex X Y list
	'((:vlr-modified . act:vlrmodified))
)


;***************************** CallBacks Routines *********************************

(defun act:vlrmodified ( owner reactor params / ReactorList )
	(princ "\n***Object Reactor triggered.")
	(setq ReactorList (cons reactor ReactorList))
	(or	*act:vlrcomended
		(setq *act:vlrcomended
			(vlr-command-reactor
				(list "LWV-Reactor" ReactorList) ;Data=Identifier + list of object reactors
				'((:VLR-commandEnded . act:vlrcomended))
			)
		)
	)
	(princ "\n***Commandended reactor has been added.")
)
(defun act:vlrcomended ( reactor cmd / )
	(setq ReactorList (cadr (vlr-data reactor)))
	(foreach r ReactorList
		;(vlr-remove r)
		(setq ent (vlax-vla-object->ename (car (vlr-owners r))))
		(setq xd (cadadr (assoc -3 (entget ent '("*")))))
		(setq Ovlst (cadr (vlr-data r))) ;Original LW vertex X Y list
		(setq Nvlst (vlax-get (car (vlr-owners r)) 'Coordinates)) ;New LW vertex X Y list
		(vlr-remove r)
		(if (equal Ovlst Nvlst)
			(princ "\n***Object Not Modified.")
			(progn
				(setq xd (cons 1070 (1+ (cdr xd))))  
				(entmod (list (cons -1 ent) (list -3 (list "XDlwvertex" xd))))
				(princ "\n***Object Modified.")
			)
		)
		(vlr-data-set r (list "LWV-Reactor" Nvlst))
		(vlr-add r)
	)
	(setq ReactorList nil)
	(princ (strcat "\n***" (car cmd) " Command ended reactor completed."))
)

 

0 Likes
745 Views
5 Replies
Replies (5)
Message 2 of 6

doaiena
Collaborator
Collaborator

I thought we have already gone through this a while ago.
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-get-the-latest-modified-entit... 

 

You are still stubbornly going back to command reactors for tracking entity modification. There are multiple ways to track entities, but it all depends on the use case. This code doesn't look right. For some reason you are using reactors to add more reactors... which is a bad idea. What is your ultimate goal?

0 Likes
Message 3 of 6

_Bilal
Advocate
Advocate

My goal here in this post, is to track any vertex modification done by the user on an LWpolyline, is there any complete autolisp code in this regard? 

0 Likes
Message 4 of 6

doaiena
Collaborator
Collaborator

In that case use an object reactor.

I don't know if there is a complete solution ready for you. If you search the web you might find something useful.

0 Likes
Message 5 of 6

_Bilal
Advocate
Advocate

I got two codes one from Gile and the other from Lee Mac, but they both have the same problem when using PROPERTIES Command.

0 Likes
Message 6 of 6

doaiena
Collaborator
Collaborator

This should work with the "properties" pallete.

 

(defun ReactorFun (polyObj Reactor lst)
(princ "\nMODIFIED!\n")
)

(setq objectReactor (vlr-object-reactor (list polyObj) nil '((:vlr-modified . ReactorFun))))
0 Likes