本帖最后由 王鹏_pBZlo 于 2020-7-16 16:19 编辑
注意: 自己按实际修改第1-4句关于X1,X2,Y1,Y2的赋值,程序中都是50,无需画出小矩形
 - (defun c:tt( / x1 x2 y1 y2 xi xa yi ya xc yu yc yd ss osm i ent ptlst sstxt txt1 txt2 txt3 txt1par txt2par)
- (setq x1 50)
- (setq x2 50)
- (setq y1 50)
- (setq y2 50)
- (setq ss (ssget (list (cons 0 "LWPOLYLINE")(cons 90 4)(cons 70 1))))
- (if (not ss) (vl-exit-with-value 0))
- (command "undo" "be")
- (setq osm (getvar "osmode"))
- (setvar "osmode" 0)
- (command "ucs" "")
- (setq i -1)
- (while (setq ent (ssname ss (setq i (1+ i))))
- (setq ptlst (vl-remove-if (function (lambda(e) (/= 10 (car e)))) (entget ent)))
- (setq ptlst (mapcar 'cdr ptlst))
- (setq xi (min (car (car ptlst)) (car (caddr ptlst))))
- (setq xa (max (car (car ptlst)) (car (caddr ptlst))))
- (setq yi (min (cadr (car ptlst)) (cadr (caddr ptlst))))
- (setq ya (max (cadr (car ptlst)) (cadr (caddr ptlst))))
- (setq xc (* 0.5 (- (+ xi x1 xa) x2)))
- (setq yc (* 0.5 (- (+ yi y1 ya) y2)))
- (setq yu (+ (* 0.75 (- ya y2)) (* 0.25 (+ yi y1))))
- (setq yd (+ (* 0.25 (- ya y2)) (* 0.75 (+ yi y1))))
- (command "zoom" "o" ent "")
- (if (setq sstxt (ssget "w" (car ptlst) (caddr ptlst) (list (cons 0 "TEXT"))))
- (progn (setq txt1 (ssname sstxt 0) txt2 (ssname sstxt 1))
- (if (and txt2 (> (caddr (assoc 11 (entget txt2))) (caddr (assoc 11 (entget txt1)))))
- (setq txt3 txt1 txt1 txt2 txt2 txt3 txt3 nil)
- )
- (setq txt1par (entget txt1))
- (setq txt1par (subst (cons 71 0) (assoc 71 txt1par) txt1par))
- (setq txt1par (subst (cons 72 4) (assoc 72 txt1par) txt1par))
- (setq txt1par (subst (cons 73 0) (assoc 73 txt1par) txt1par))
- (if txt2
- (progn (setq txt2par (entget txt2))
- (setq txt2par (subst (cons 71 0) (assoc 71 txt2par) txt2par))
- (setq txt2par (subst (cons 72 4) (assoc 72 txt2par) txt2par))
- (setq txt2par (subst (cons 73 0) (assoc 73 txt2par) txt2par))
- (setq txt2par (subst (list 11 xc yd) (assoc 11 txt2par) txt2par))
- (entmod txt2par)
- (setq txt1par (subst (list 11 xc yu) (assoc 11 txt1par) txt1par))
- (entmod txt1par)
- )
- (entmod (subst (list 11 xc yc)(assoc 11 txt1par) txt1par))
- )
- )
- ) (command "zoom" "P")
- ) (setvar "osmode" osm)
- (command "undo" "e")
- (princ)
- )
注意: 自己按实际修改第1-4句关于X1,X2,Y1,Y2的赋值,程序中都是50,无需画出小矩形
|