The Command Reactors doen't work in PROPERTIES command!?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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."))
)