(defun C:DTBox(/ b bname diment ent enx h i j l lst n o r ss w)
(if (setq i -1 ss (ssget '((0 . "DIMENSION"))))
(while (setq diment (ssname ss (setq i (1+ i))))
(setq bname (cdr (assoc 2 (entget diment))))
(setq ent (tblobjname "Block" bname))
(while ent
(setq enx (entget ent))
(if (equal (assoc 0 enx) '(0 . "MTEXT"))
(setq ent nil)
(setq ent (entnext ent))
)
)
(setq
n (cdr (assoc 210 enx))
b (trans (cdr (assoc 10 enx)) 0 n)
r (angle '(0.0 0.0 0.0) (trans (cdr (assoc 11 enx)) 0 n))
w (cdr (assoc 42 enx))
h (cdr (assoc 43 enx))
j (cdr (assoc 71 enx))
o (list
(cond
((member j '(2 5 8)) (/ w -2.0))
((member j '(3 6 9)) (- w))
(0.0)
)
(cond
((member j '(1 2 3)) (- h))
((member j '(4 5 6)) (/ h -2.0))
(0.0)
)
)
l ((lambda (m)
(mapcar '(lambda (p) (mapcar '+ (mapcar '(lambda (r) (apply '+ (mapcar '* r p))) m) b))
(list
(list (car o) (cadr o))
(list (+ (car o) w) (cadr o))
(list (+ (car o) w) (+ (cadr o) h))
(list (car o) (+ (cadr o) h))
)
)
)
(list
(list (cos r) (sin (- r)) 0.0)
(list (sin r) (cos r) 0.0)
'(0.0 0.0 1.0)
)
)
lst (mapcar '(lambda (x) (trans x n 0)) l)
)
(entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length lst)) (cons 70 1)) (mapcar '(lambda(pt) (cons 10 pt)) lst)))
)
)
(prin1)
)
(defun c:fk(/ flg i s ss vs)
(princ "\n【添加或删除尺寸的方框】")
(setq i (getvar "dimscale"))
(setvar "regenmode" 1)
(setvar "cmdecho" 0)
(while (setq s (entsel))
(setq s (car s))
(if (= "DIMENSION" (cdr (assoc '0 (setq ss (entget s)))))
(progn
(setq vs (vlax-ename->vla-object s))
(setq flg (vla-get-TextGap vs))
(if (< flg 0)
(vla-put-TextGap vs (abs flg))
(vla-put-TextGap vs (- 0 flg))
)
)
)
)
(princ)
)