Cross posted to The Swamp.
Adding GUIDs to my application entities to enable up and back capability to a GIS system. In any drawing, upon opening (approx. 4 sec for 35k entities), a lsp routine creates current a list of all relevant entities ((GUID ename #vla)...). I have created a reactor which deletes entities from the list when they are erased.
I need a similar reactor to replace the (GUID ename #vla) data to the list upon undo. I have the reactor working, but cannot get the GUID from the restored entity because I do not know how to use activex functions (and in general as well) to pull the data field from the table attached to the entity (aed_od functionality).
So I am asking for help, a code snippet if possible, that returns a specific field from a specific table when given "vla-object name".
To use the attached code and drawing:
1st: Open the attached dwg and loading the attached lsp.
2nd: Execute c:er command. It activates the reactors and builds the initial reference list "#MonLst".
3rd: Delete a line from the drawing. The "Erase Object" reactor removes that pline from the list "#MonLst".
4th: Undo. The "unErase Object" reactor replaces the all but the GUID from the object in the updated list "#MonLst".
Below is the code used (apologies if poorly formatted).
;;; Create list of objects to monitor ;
(defun c:er (/ entmon guid objmon ssmon x)
(setq ssMon (ssget x '((0 . "LWPOLYLINE") (8 . "0")))
objMon (ss->VLA ssMon)
entMon (ss->ent ssMon)
#MonLst '()
)
(foreach obMon objMon ; attach reactors to ojbects
(VLR-Object-Reactor (list obMon) "Erase Object" '((:vlr-erased . delobj)))
(VLR-Object-Reactor (list obMon) "unErase Object" '((:vlr-unerased . undelobj)))
)
(foreach en entMon ; make reference list
(if (setq GUID (ade_odgetfield en "stlGUID" "GUID" 0))
(setq #MonLst
(cons
(list GUID en (vlax-Ename->Vla-Object en))
#MonLst
)
)
) ;if
)
)
;;; Reactor Remove from list - This one works ;
;;; (VLR-Object-Reactor objMon "Erase Object" '((:vlr-erased . delobj)))
(defun delobj (notifier-object reactor-object parameter-list)
(setq #MonLst (vl-remove-if (setq what (function (lambda (x) (equal (caddr x) notifier-object)))) #MonLst))
)
;;; END ;
;;; Reactor Replace in list - This one cannot retrieve the value in the GUID field. ;
;;; (VLR-Object-Reactor (list obMon) "unErase Object" '((:vlr-unerased . undelobj)))
(defun undelobj (notifier-object reactor-object parameter-list)
(setq #MonLst
(cons
(list
;; This line does not work due to using the non-activeX function "ade_odgetfield" and ename
(ade_odgetfield (vlax-vla-object->ename notifier-object) "stlGUID" "GUID" 0)
;; The following two lines work
(vlax-vla-object->ename notifier-object)
notifier-object
) ; list
#MonLst) ; cons
) ; setq
)
;;; END ;
;;; Many thanks to Lee Mac for the following functions I use everywhere:
(defun ss->vla ( sel / idx lst )
(if (= 'pickset (type sel))
(repeat (setq idx (sslength sel))
(setq lst (cons (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) lst))
)
)
)
(defun ss->ent ( ss / i l )
(if ss
(repeat (setq i (sslength ss))
(setq l (cons (ssname ss (setq i (1- i))) l))
)
)
)