http://bbs.mjtd.com/forum.php?mod=viewthread&tid=89669&highlight=%B0%FC%CE%A7%BF%F2
(defun C:MinBox(/ ent i maxp maxx0 maxy0 minp minx0 miny0 pmax pmin ss)
(vl-load-com)
(if (setq ss (ssget))
(progn
(setq minx0 1e6 miny0 1e6 maxx0 -1e6 maxy0 -1e6 i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(vla-getboundingbox (vlax-ename->vla-object ent) 'minp 'maxp)
(setq minp (vlax-safearray->list minp) maxp (vlax-safearray->list maxp))
(setq
minx0 (min minx0 (car minp))
miny0 (min miny0 (cadr minp))
maxx0 (max maxx0 (car maxp))
maxy0 (max maxy0 (cadr maxp))
)
)
(setq pmin (list minx0 miny0) pmax (list maxx0 maxy0))
(command ".rectang" "non" pmin "non" pmax)
)
)
(princ)
)
(defun MinBoxPts(ss / ent i maxp maxx0 maxy0 minp minx0 miny0 pmax pmin)
(if ss
(progn
(setq minx0 1e6 miny0 1e6 maxx0 -1e6 maxy0 -1e6 i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(vla-getboundingbox (vlax-ename->vla-object ent) 'minp 'maxp)
(setq minp (vlax-safearray->list minp) maxp (vlax-safearray->list maxp))
(setq
minx0 (min minx0 (car minp))
miny0 (min miny0 (cadr minp))
maxx0 (max maxx0 (car maxp))
maxy0 (max maxy0 (cadr maxp))
)
)
(setq pmin (list minx0 miny0) pmax (list maxx0 maxy0))
(list pmin pmax)
)
nil
)
)