In a
visual basic thread there's a discussion regarding grabbing the attach state (overlay / attach). Quite frankly it's a pain using the object model, at least based on my investigations many years ago.
Here's how I do it in lisp for documents opened via Object DBX (not for the active documents collection et al, see brief comment in the function declaration). Sorry, it's not overlay documented, and well, I'm playing the "I don't have time card".
An aside, I made loose reference to the function below (part of a large app I wrote for one of my clients called 'Carnivore') in
this conversation with Mr. Madsen many moons ago, you may find it interesting; or not.
FWIW ... Cheers.
(defun GetXrefsAttachState ( AxDbDocument / _Put _IncHex _Main )
;; GetXrefsAttachState
;;
;; Use to get the attach / oerlay state from ObjectDBX
;; documents. While you can use on 'normal' documents, i.e.
;; like the active document, that would be dumb (use
;; traditional dxf methods instead).
;;
;; typical call and results
;;
;; (GetXrefsAttachState ValidAxDbDocument)
;;
;; (
;; ("Drawing1" "Attach" 1)
;; ("Drawing2" "Overlay" 1)
;; ("Drawing3" "Overlay" 2)
;; )
;;
;; The number indicates the xref instances found
(defun _Put ( item position lst )
( (lambda ( i )
(mapcar
'(lambda ( x )
(if (eq position (setq i (1+ i)))
item
x
)
)
lst
)
)
-1
)
)
(defun _IncHex ( hex )
( (lambda ( lst i / j a b )
(while (setq a (nth (setq i (1+ i)) lst))
(cond
( (< 70 a) ; "G" and greater
(setq lst
(if (setq b (nth (setq j (1+ i)) lst))
(_Put (1+ b) j (_Put 48 i lst))
(append (_Put 48 i lst) (list 49))
)
)
)
( (eq 58 a) ; ":"
(setq lst (_Put 65 i lst)) ; replace w/"A"
)
)
)
(vl-list->string (reverse lst))
)
(cons
(1+
(car
(setq lst
(reverse
(vl-string->list
(strcase hex)
)
)
)
)
)
(cdr lst)
)
-1
)
)
(defun _Main ( AxDbDocument / Object Ename Data Result )
(vlax-for Block
(vlax-get-property
AxDbDocument
'Blocks
)
(cond
( (and
(eq :vlax-true
(vlax-get-property
Block
'IsXref
)
)
(null
(vl-catch-all-error-p
(setq Object
(vl-catch-all-apply
'vlax-invoke-method
(list
AxDbDocument
'HandleToObject
(_IncHex
(vlax-get-property
Block
'Handle
)
)
)
)
)
)
)
(null
(vl-catch-all-error-p
(setq Ename
(vl-catch-all-apply
'vlax-vla-object->ename
(list Object)
)
)
)
)
(null
(vl-catch-all-error-p
(setq Data
(vl-catch-all-apply
'entget
(list Ename)
)
)
)
)
(eq "BLOCK" (cdr (assoc 0 Data)))
;; If you want this is where'd you'd
;; add additional properties like the
;; xref path, flag values ad nauseum.
)
(setq Result
(cons
(list
(cdr (assoc 2 Data))
(if (eq 8 (logand 8 (cdr (assoc 70 Data))))
"Overlay"
"Attach"
)
(length
(vl-remove-if-not
'(lambda (x) (eq 331 (car x)))
(entget (vlax-vla-object->ename Block))
)
)
)
Result
)
)
)
)
)
Result
)
(_Main AxDbDocument)
)
Cludgy? Perhaps. It is what it is and offered at face value.