以下代码也是从论坛得来的凑的,想不需要用户选择的情况下获得最大包围盒。但在碰到图框块元素时出错了,哪位大佬能帮看看么?感谢。
- (defun c:ctx(/ dd gbo p1 p2 p3 p4 ps pxa pxb pya pyb ss)
- (setvar "cmdecho" 0)
- (defun gbo(obj / p1 p2)(vla-getboundingbox obj 'p1 'p2)(mapcar 'vlax-safearray->list (list p1 p2)))
- (setq filter '((0 . "*LINE,ARC,ELLIPSE,CIRCLE,TEXT,POINT,ATTDEF,RECTANG,INSERT")))
- (setq ss (ssget "X" filter))
- (setq dd (*(getvar "dimscale")6))
- (setq ps (mapcar 'gbo(mapcar 'vlax-ename->vla-object(vl-remove-if 'listp(mapcar 'cadr(ssnamex ss))))))
- (setq pxa (apply 'min(mapcar 'caar ps)))
- (setq pya (apply 'min(mapcar 'cadar ps)))
- (setq pxb (apply 'max(mapcar 'caadr ps)))
- (setq pyb (apply 'max(mapcar 'cadadr ps)))
- (setq p1 (list pxa pya))
- (setq p2 (list pxb pya))
- (setq p3 (list pxb pyb))
- (setq p4 (list pxa pyb))
- (princ p1)
- (princ p2)
- (princ p3)
- (princ p4)
- (prin1)
- )
|