@Kent1Cooper wrote:
@ronjonp wrote:
Maybe something as simple as this?
(setq e (bpoly (getpoint)))
It will return the ename of the boundary that you can use to get your selection set.
Is there a (bpoly) AutoLisp function that's not documented? It seems so in quick trial, but without documentation I can't tell how the result might be affected by surrounding conditions. But whether I use the insertion point of an inner Block for the point in that, or in a BPOLY command, since the insertion point is in the middle of the little Block [in the sample drawing, at least], the resulting Polyline is just within that Block, and does not go to the outer one that would presumably outline the surrounding Block with the Attribute they want to get the value from. If there's ever anything like a Line drawn across the surrounding one, that will limit the resulting Polyline's reach, so that using the Polyline's vertices in the WP option in (ssget) won't find that outer Block.
@Kent1Cooper Thanks for the description Kent .. this is essentially describing what the boundary command does. My offering was just an idea not a fool proof solution. The thought was to use a crossing selection for the check but even that could be fooled with adjacent blocks. 🍻
This is probably how I'd approach this problem after thinking about it a bit more 🙂
(defun c:foo (/ a c d p r s)
;; Viewport Extents - Lee Mac
;; Returns two WCS points describing the lower-left and
;; upper-right corners of the active viewport.
(defun lm:viewportextents (/ c h v)
(setq c (trans (getvar 'viewctr) 1 0)
h (/ (getvar 'viewsize) 2.0)
v (list (* h (apply '/ (getvar 'screensize))) h)
)
(list (mapcar '- c v) (mapcar '+ c v))
)
;; RJP » 2020-11-10
(setq a (lm:viewportextents))
(cond ((and (setq p (getpoint "\nPick a point:"))
(setq s (ssget "_C" (car a) (cadr a) '((0 . "INSERT") (66 . 1))))
(setq s (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
)
(while (and (null r) (car s))
(vla-getboundingbox (vlax-ename->vla-object (car s)) 'c 'd)
(mapcar 'set '(c d) (mapcar 'vlax-safearray->list (list c d)))
(cond ((and (<= (car c) (car p) (car d)) (<= (cadr c) (cadr p) (cadr d)))
(setq r (car s))
(redraw r 3)
(if (= 'str (type (vl-catch-all-apply 'getpropertyvalue (list r "ATTx"))))
(alert (getpropertyvalue r "ATTx"))
(alert "Block does not have 'ATTx'TAGNAME!")
)
)
)
(setq s (cdr s))
)
)
)
(princ)
)