WHM Posted May 5, 2022 Posted May 5, 2022 Good day all, It seems like I've been posting daily lately! A quick one - (or so I think) I've just started learning/using reactors today. I'd like to get an entities xdata before it gets deleted, I'm pretty sure I can't retrieve it after it gets deleted so is it possible to grab the xdata when the entity is selected and to store the xdata when it actually gets deleted? I had another thought that I might try, when the entity gets deleted it temporarily gets restored to grab the xdata before it gets deleted again. Here is my code so far, please tear it up and let me know if I'm doing anything wrong. (defun c:test (/ ent) (setq ent (car (entsel))) (reactor:modified (vlax-ename->vla-object ent)) ) (defun reactor:modified (vlaent) (setq modify-reactor (vlr-object-reactor (list vlaent) "Reactor" '((:vlr-modified . entity-modify) (:vlr-erased . entity-erased)))) (princ) ) (defun entity-erased (notifier-object reactor-object parameter-list) (vla-GetXData notifier-object "1MAPID" 'xType 'xData) (setq 1mapid (cadr (_VariantToLispData xData))) (if (not (member 1mapid *1MAPDELETED*)) (setq *1MAPDELETED* (cons 1mapid *1MAPDELETED*))) (princ) ) (defun entity-modify (notifier-object reactor-object parameter-list) (vla-GetXData notifier-object "1MAPID" 'xType 'xData) (setq 1mapid (cadr (_VariantToLispData xData))) (if (not (member 1mapid *1MAPMODIFIED*)) (setq *1MAPMODIFIED* (cons 1mapid *1MAPMODIFIED*))) (princ) ) (defun _VariantToLispData (var) (cond ((= (type var) 'variant) (_VariantToLispData (vlax-variant-value var))) ((= (type var) 'safearray) (mapcar '_VariantToLispData (vlax-safearray->list var))) (T var) ) ) Quote
WHM Posted May 6, 2022 Author Posted May 6, 2022 Alright so this was quite a bit more difficult, so instead of reacting on deletion I've gone and created a list on startup that stores all the entity handle names and when I'm ready to see what has been deleted I go through the list and see what I can't find. Reactors are pretty difficult! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.