本帖最后由 飞雪神光 于 2023-5-9 07:37 编辑
- ;;最大外围框
- (defun c:tes (/ &kw ent s1905271 ss1 sx x1 x1903211 x2 y1 y2)
- (vl-load-com)
- ;长度为整数
- (defun s1905271 (i1 i2 / i i1 i2 i3 i4)
- (setq i3 (* 0.5 (+ i2 i1)) i4 (- i2 i1) i (atof (rtos i4 2 0)))
- (if (> i4 i) (setq i (+ i 1)) )
- (setq i (* 0.5 i))
- (list (- i3 i) (+ i3 i))
- )
- (defun x1903211 (obj / obj x y)
- (vla-getboundingbox obj 'x 'y)
- (mapcar 'vlax-safearray->list (list x y));点表
- )
- (princ "\n请选择对象")
- (if (setq &kw (ssget))
- (progn
- (setq ss1 '())
- (while (setq ent (ssname &kw 0))
- (setq &kw (ssdel ent &kw) ss1 (cons ent ss1))
- );while
- (setq ss1 (mapcar 'vlax-ename->vla-object ss1))
- (setq ss1 (apply 'append (mapcar 'x1903211 ss1)))
- (setq sx (vl-sort (mapcar 'car ss1) '<))
- (setq x1 (car sx) x2 (last sx))
- (setq sx (s1905271 x1 x2) x1 (car sx) x2 (cadr sx))
- (setq sx (vl-sort (mapcar 'cadr ss1) '<))
- (setq y1 (car sx) y2 (last sx))
- (setq sx (s1905271 y1 y2) y1 (car sx) y2 (cadr sx))
- (setq x1 (- x1 10) x2 (+ x2 10) y1 (- y1 10) y2 (+ y2 10))
- (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) '(38 . 0) (cons 10 (list x1 y1)) (cons 10 (list x2 y1)) (cons 10 (list x2 y2)) (cons 10 (list x1 y2))))
- )
- )
- (princ)
- )
|