http://bbs.mjtd.com/forum.php?mod=viewthread&tid=89669&highlight=%B0%FC%CE%A7%BF%F2

    1. (defun C:MinBox(/ ent i maxp maxx0 maxy0 minp minx0 miny0 pmax pmin ss)
    2. (vl-load-com)
    3. (if (setq ss (ssget))
    4. (progn
    5. (setq minx0 1e6 miny0 1e6 maxx0 -1e6 maxy0 -1e6 i -1)
    6. (while (setq ent (ssname ss (setq i (1+ i))))
    7. (vla-getboundingbox (vlax-ename->vla-object ent) 'minp 'maxp)
    8. (setq minp (vlax-safearray->list minp) maxp (vlax-safearray->list maxp))
    9. (setq
    10. minx0 (min minx0 (car minp))
    11. miny0 (min miny0 (cadr minp))
    12. maxx0 (max maxx0 (car maxp))
    13. maxy0 (max maxy0 (cadr maxp))
    14. )
    15. )
    16. (setq pmin (list minx0 miny0) pmax (list maxx0 maxy0))
    17. (command ".rectang" "non" pmin "non" pmax)
    18. )
    19. )
    20. (princ)
    21. )
    1. (defun MinBoxPts(ss / ent i maxp maxx0 maxy0 minp minx0 miny0 pmax pmin)
    2. (if ss
    3. (progn
    4. (setq minx0 1e6 miny0 1e6 maxx0 -1e6 maxy0 -1e6 i -1)
    5. (while (setq ent (ssname ss (setq i (1+ i))))
    6. (vla-getboundingbox (vlax-ename->vla-object ent) 'minp 'maxp)
    7. (setq minp (vlax-safearray->list minp) maxp (vlax-safearray->list maxp))
    8. (setq
    9. minx0 (min minx0 (car minp))
    10. miny0 (min miny0 (cadr minp))
    11. maxx0 (max maxx0 (car maxp))
    12. maxy0 (max maxy0 (cadr maxp))
    13. )
    14. )
    15. (setq pmin (list minx0 miny0) pmax (list maxx0 maxy0))
    16. (list pmin pmax)
    17. )
    18. nil
    19. )
    20. )