SeaHaven,
I've been trying to get the ss2 selection set (contains just the Attributes), to be 'selected' for
the Properties window, like Ctrl + Left click. - Doesn't work. I tried 'select' and 'pselect' (undocumented),
no joy. So, the bottom line, 'because' the Attribute is within the Block, when you select just the Attribute,
you get the 'whole' block, not just that Attribute. So I came up with a modification of get_atts.lsp as originally
posted. Named it get_atts2.lsp (code window). It takes each of those selected Attributes, and adds "XXX"
to the TextString, and does an (entmod .. on them. It demonstrates that you 'can' get those Arrributes into
a Selection Set (ss2), but you cannot grip / select them without getting the whole Block. Don't know how
the Ctrl + Left Click does it. Seems to be just a 'nentsel' type of operation, with a twist that it gets multiples.
???
For what it's worth, this is the new code.
;; GET_ATTS2.lsp
;; Function: to get a selection set of just 'Attributes' "ATTDEF"'s that fall within a Window.
;; Function to determine if the ATTDEF falls within a window, based on it's insertion point.
;; Send in Selection Set, and Window Points
(vl-load-com)
(defun is_in_window ( ss P1 P2 ); returns ss2, attdef's with insertion points 'inside' window.
(if ss
(progn
(setq X1 (car P1) Y1 (cadr P1)); Window points P1, X & Y
(setq X2 (car P2) Y2 (cadr P2)); Window points P2, X & Y
(if (> X1 X2); Windowed from Right to Left - swap points
(setq T1 X1 X1 X2 X2 T1 T2 Y1 Y1 Y2 Y2 T2); CORRECTED
;(setq T1 X1 X2 X1 X1 T1 T2 Y1 Y1 Y2 Y2 T2); original was incorrect
); if
(setq N (sslength ss) I 0)
(repeat N
(setq blk (vlax-ename->vla-object (ssname ss I)))
(if (safearray-value (setq atts (vlax-variant-value (vla-getattributes blk))))
(progn
(setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))
(foreach att atts
(setq nam (vla-get-objectname att))
(if (= nam "AcDbAttribute")
(progn
(setq IP (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint att))))
(setq X (car IP) Y (cadr IP))
(if (and (> X X1)(< X X2)(> Y Y2)(< Y Y1))
(progn
(setq ent (vlax-vla-object->ename att))
(setq elist (entget ent))
(setq txt (cdr (assoc 1 elist)))
(if txt
(progn
(if (/= txt "") ; do not include blank attributes
(setq ss2 (ssadd ent ss2)); add to Selection set
); if
); progn
); if
); progn
); if it is in window
); progn
); if nam =
); foreach
); progn
); if safe array
(setq I (+ I 1))
); repeat
); progn
); if ss
(princ)
); function
(defun C:GO ( )
;; Get the selection set
;;
(setq ss2 (ssadd)); blank selection set
(princ "\n")
(princ "\nPick Windows or Enter Key to Stop:"); instructions
(while
(setq P1 (getpoint "\nPick 1st Window Point"))
(setq P2 (getcorner P1 "\nPick 2nd Window Point"))
(if (and (/= P1 nil)(/= P2 nil))
(progn
(setq ss1 (ssget "C" P1 P2 (list (cons 0 "INSERT"))))
(is_in_window ss1 P1 P2); add Attributes within window to ss2 selection set
); progn
); if P1/P2
(setq P1 nil P2 nil)
); while
;; Select the attributes one at a time & 'do' something to them.
(if (> (sslength ss2) 0)
(progn
(setq N 0)
(repeat (sslength ss2)
(setq ent (ssname ss2 N))
(setq elist (entget ent)); Entity List
;; This section just adds "XXX" to the TextString of each Selected Attribute
(setq txt (cdr (assoc 1 elist))); Text String
(setq txt (strcat txt "XXX"))
(entmod (setq elist (subst (cons 1 txt)(assoc 1 elist) elist))); CONStruct replacement Text
(entupd (ssname ss2 N))
;; If you wanted to change the Location, you would need to modify the (assoc 10 elist)
;; or other things like (assoc 62 "color"), (assoc 40 Height) ..
(setq N (+ N 1))
); repeat
); progn
); if
(princ)
); function C:GO
(princ "\nType GO to run:")
ECCAD