在论坛上找的 不知道是谁做的了
- (defun C:wx()
- (vl-load-com)
- (command "undo" "be")
- (setvar "cmdecho" 0)
- (command "ucs" "w")
- (princ "\n请选择物体:")
- (while(null(setq en (ssget))))
- (setq minx0 1e6 miny0 1e6 maxx0 -1e6 maxy0 -1e6)
- (setq i 0)
- (repeat (sslength en)
- (setq end (ssname en i))
- (setq end_data (entget end))
- (Min_Max)
- (setq i(1+ i))
- )
- (setq pmin (list minx0 miny0)
- pmax (list maxx0 maxy0))
- (command ".rectang" "non" pmin "non" pmax)
- (command "undo" "e")
- (princ)
- )
- ;;;子程序,求选集是大外形坐标
- (defun Min_Max()
- (vla-getboundingbox(vlax-ename->vla-object end) 'minp 'maxp)
- (setq minp (vlax-safearray->list minp)
- maxp (vlax-safearray->list maxp))
- (setq minx (car minp)
- maxx (car maxp)
- miny (cadr minp)
- maxy (cadr maxp))
- (if (> minx0 minx) (setq minx0 minx))
- (if (> miny0 miny) (setq miny0 miny))
- (if (< maxx0 maxx) (setq maxx0 maxx))
- (if (< maxy0 maxy) (setq maxy0 maxy))
- )
|