lisp求最大外形矩形 ,如何才能将选择集内所有对象进行循环单独绘制最大外形矩形??谢谢 10
(defun try-getbox (e / en i l max1 min1 pt1 pt2 sn tx1 tx2 ty1 ty2 tye x1 x2 y1 y2)
(setq tye(type e))
(cond
((= 'VLA-object tye)
(vla-GetBoundingBox e 'p1 'p2)
(setq min1 (vlax-safearray->list p1))
(setq max1 (vlax-safearray->list p2))
(list min1 max1)
)
((= 'ENAME tye)
(try-GetBox (vlax-ename->vla-object e))
)
((or(= 'LIST tye)(= 'PICKSET tye))
(if (= 'PICKSET tye)(setq e (repeat (sslength ss)
(setq l(cons (vlax-ename->vla-object(ssname ss(setq i(1+ i)))) l))
)))
(if (= ENAME(type(car e)))(setq e(mapcar 'vlax-ename->vla-object e)))
(vla-getboundingbox (car e) 'pt1 'pt2)
(setq
pt1(vlax-safearray->list pt1)
pt2 (vlax-safearray->list pt2)
tx1 (car pt1)
ty1 (cadr pt1)
tx2 (car pt2)
ty2 (cadr pt2)
)
(setq i 0)
(setq sn (length e))
(repeat (1- sn)
(setq en (nth (setq i (1+ i))e))
(vla-getboundingbox en 'pt1 'pt2)
(setq
pt1(vlax-safearray->list pt1)
pt2 (vlax-safearray->list pt2)
x1 (car pt1)
y1 (cadr pt1)
x2 (car pt2)
y2 (cadr pt2))
(if (> tx1 x1)(setq tx1 x1))
(if (> ty1 y1)(setq ty1 y1))
(if (< tx2 x2)(setq tx2 x2))
(if (< ty2 y2)(setq ty2 y2))
)
(list (list tx1 ty1) (list tx2 ty2))
)
)
)
如何使用代码,能直接复制文本,做成CAD命令吗?