(defun c:autodimlines ()
(setq ss (ssget '((0 . "line"))))
(setq number (sslength ss))
(setq i 0)
(repeat number
(setq entname (ssname ss i))
(setq ent (entget entname))
(setq point_a (cdr (assoc 10 ent)))
(setq point_b (cdr (assoc 11 ent)))
(setq d (* -0.2 (distance point_a point_b)))
(command "dimaligned" point_a point_b point_b)
(setq ent (entget(entlast)))
(setq x1 (car point_a) y1 (cadr point_a) x2 (car point_b) y2 (cadr point_b))
(setq point (calculate_dalposition x1 y1 x2 y2 d))
(entmod (subst (cons 10 point) (assoc 10 ent) ent) )
(setq i (+ i 1))
)
)
(defun calculate_dalposition (x1 y1 x2 y2 d)
(if (/= (- y2 y1) 0)
(progn
(setq k (/ (- x1 x2) (- y2 y1)) )
(setq thita (atan k))
(if (< thita 0)
(setq thita1 (+ 3.1415926 thita) thita2 (* -1 thita))
(setq thita1 thita thita2 thita)
)
(setq x (- x2 (* d (cos thita1))))
(setq y (- y2 (* d (sin thita2))))
(list x y)
)
(progn
(setq y (- y2 d) x x2)
(list x y)
)
)
)
不知道cad能运行不 浩辰 可以