@Kent1Cooper wrote:
....
The problem is with all those invisible Attributes that expand the extents far beyond the visible extents of the pieces in the Group. If the configuration of such things is always similar, it could be made to ... use only the bounding box of any closed Polyline it finds....
This does that, except that it uses the first Polyline it finds [whether or not closed -- it could have that restriction added, and/or the number of sides, etc., if there could be more than one Polyline in a Group]. So it isn't bothered by the invisible Attributes, and does the spacing correctly. But that means the kinds of things in the Group need to be always similar in nature to your example. It could base it on the Hatch pattern instead, if that's more consistent, or something else.
And it asks you in which orthogonal direction you want more Groups added. [It could be any angle, given some criteria about the resulting relationship.] It's up to you to control where the Block's visible Attribute sits in relation to the rest -- for example, if you use the Up or Down choice here with your sample Group, the rectangles in the Groups will touch, and that Block will show [in all but one of them at an end] inside the adjacent Group's rectangle.
Lightly tested:
(defun C:WHATEVER (/ ss n dir ent LL UR gotit)
(prompt "\nSelect Group to Array: ")
(if (setq ss (ssget ":S"))
(progn ; then
(initget 1 "Left Right Up Down")
(setq
n (sslength ss)
dir (getkword "\nArrayed in what direction [Left/Right/Up/Down]: ")
); setq
(while (not gotit)
(setq ent (ssname ss (setq n (1- n))))
(if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
(progn
(vla-getboundingbox (vlax-ename->vla-object ent) 'minpt 'maxpt)
(setq
LL (vlax-safearray->list minpt)
UR (vlax-safearray->list maxpt)
delta (mapcar '- UR LL) ; XY of difference across corners
gotit T ; stop (while) loop
); setq
); progn
); if
); while
(command "_.array" ss "" "_rectangular")
(if (wcmatch dir "Left,Right")
(command 1 (1+ (getint "\nAdd how many ? "))); then [1 row, ask for columns]
(command (1+ (getint "\nAdd how many? ")) 1); else [ask for rows, 1 column]
); if
(command
(cond
((= dir "Left") (- (car delta)))
((= dir "Right") (car delta))
((= dir "Up") (cadr delta))
((= dir "Down") (- (cadr delta)))
); cond
); command
); progn
(prompt "\nNothing selected."); else
); if
(princ)
); defun
Kent Cooper, AIA