Don't think ALERT is allowed in a reactor.I swear it has worked for me in the past. :?
Try (princ "\nnil value)
I was just guessing. Didn't feel like testing it. :-(I figured as much, just wanted to share my experience... or at least try and remember it. :lol:
Don't think ALERT is allowed in a reactor.
Try (princ "\nnil value)
What are you trying to do to the objects before the erase?
Another version where the objecterased reactor is only on during the ERASE command.
(setq id_obj (ReadXdata obj "NAMEAPP" "ID"))
(defun ReadXdata (ogg nomeapp labeldato / dato elist exlist thexdata labelfind dato nX sublista)
(setq nX 0)
(setq elist (entget ogg (list nomeapp)))
(setq exlist (assoc -3 elist))
(if (/= exlist nil)
(progn
(setq thexdata (cdr (car (cdr exlist))))
;--
(setq sublista (nth nX thexdata))
(if sublista
(setq labelfind (splittaemi (cdr sublista) "=" 0))
(setq labelfind nil)
)
(while (/= labelfind nil)
(if (= labelfind labeldato)
(progn
(setq sublista (nth nX thexdata))
(if sublista (setq dato (splittaemi (cdr sublista) "=" 1)))
(setq labelfind nil)
)
(progn
(setq nX (+ nX 1))
(setq sublista (nth nX thexdata))
(if sublista
(setq labelfind (splittaemi (cdr sublista) "=" 0))
(setq labelfind nil)
)
)
)
)
(setq dato dato)
)
)
;--
)
;; If ERASE command then collect ename of all erased entities
(defun _ObjErased (a b / delent)
(if *EraseStarted* ; flag for ERASE command started
(progn
;; may not be necessary but check the ent list to be
;; sure the ename is not there already
(if (not (vl-position (cadr b) *ErasedList))
(setq *ErasedList (cons (cadr b) *ErasedList)) ; collect the ename
)
;; >>---> message to mommand line
(and
*CmdEraseDebug*
(alert (strcat "\n" (vl-princ-to-string (cadr b)) " Deleted From Drawing"))
;---
(setq ID (ReadXdata (cadr b) "NAMEAPP" "ID"))
(alert (strcat "ID1 = " ID))
;---
(setq ID (ReadXdata (vlax-ename->vla-object b) "NAMEAPP" "ID"))
(alert (strcat "ID2 = " ID))
;---
(setq ID (ReadXdata (vlax-ename->vla-object (cadr b) "NAMEAPP" "ID")))
(alert (strcat "ID3 = " ID))
)
;; <---<< end message
)
)
)
So it seems even here you cannot open an object to read its data while another process has it open to modify such data.
OpenMode.ForRead Up to 256 readers can be opened at once, as long as object is not already open kForWrite or kForNotify. Member functions invoked when an object is opened kForRead should not cause object to be modified.
Yes I knew my code was not a complete solution. 8-)
Untested but this should collect xData in a global variable *IDlst
This is a working version with my xData get routine.
The problem is that the xData is unavailable in a deleted entity so you must undelete it, get the xData then delete it again.
(defun get-xdata (ent appName / myData)
(entdel ent)
(setq myData (cadr (assoc -3 (entget ent (list appName)))))
(entdel ent)
myData
)
... in some cases, on the property, says that objects are two : VIEWPORT + POLYLINE.That happens on clipped viewports all the time. A clipped viewport is in fact 2 entities: the rectangular viewport and the polyline defining its boundary (even if that polyline is the exact same rectangle as the viewport). So if you select any one of them, both are selected.
(defun vp_sel (sel-vport / vpflag sel-vport entvport vptest)
(if (= (getvar "TileMode") 1) ; in model space
;;------------------------------------------------
(progn
(alert "**** You must be in Paper Space to run this routine. ****")
)
;;------------------------------------------------
(progn ;else in a layout
(if (/= (getvar "cvport") 1)
(vl-cmdf "_.pspace") ; close the view port
)
(setq vpflag (getvar "cvport")) ; get viewport #
(while (= vpflag 1) ; No active viewport, Loop until one is picked
;(setq sel-vport (car (entsel "\nSelect view port: ")))
(if (= sel-vport nil)
(alert
"You must select a viewport\r\n --=< Try again! >=--"
)
(progn
(setq entvport (entget sel-vport))
(if (and ;; not all vp objects are LWPolylines
;;(= (cdr (assoc 0 entvport)) "LWPOLYLINE")
(setq vptest (member '(102 . "{ACAD_REACTORS") entvport))
(setq vptest (member '(102 . "}") (reverse vptest)))
(assoc 330 vptest)
)
(setq entvport (entget (cdr (assoc 330 vptest))))
)
;; Make VP active
(if (= (cdr (assoc 0 entvport)) "VIEWPORT")
(progn
(setq vpflag (cdr (assoc 69 entvport)))
(vl-cmdf "_.mspace") ; activate the last vp active
(setvar "cvport" vpflag) ; switch to this vp
) ; endif viewport
)
)
) ; endif cond sel-vport
) ;endwhile (= vpFlag 1)
(vl-cmdf "_.pspace") ; close the view port
)
)
;; return the ename of vp or nil
(cond (entvport (cdr (assoc -1 entvport))))
)
(defun get-xdata (ent appName / myData a)
(entdel ent)
(setq myData (cadr (assoc -3 (entget ent (list appName)))))
(if (= (vall 0 ent) "VIEWPORT")
(progn
(setq a (vp_sel ent))
(entdel a)
)
)
(entdel ent)
myData
)