- (defun c:tt (/ a gj q1 q2 sca x1 x2 xx y1 y2 zx zz)
- (setq sca (getvar "DIMSCALE"));取得标注比例
- (setq gj (getstring "\n请输入文字:"))
- (setq zx (car (entsel "\n请选择直线:")))
- (setq xx (entget zx))
- (setq q1 (cdr (assoc 10 xx)))
- (setq q2 (cdr (assoc 11 xx))) ; 获取端点坐标
- (setq a (/ (* 180 (angle q1 q2)) pi)) ; 获取角度 弧度转为角度
- (setq x1 (car q1))
- (setq y1 (cadr q1))
- (setq x2 (car q2))
- (setq y2 (cadr q2))
- (setq zz (list (/ (+ x1 x2) 2) (/ (+ y1 y2) 2))) ; 求中点坐标
- (command "text" zz (* sca 4) a gj) ; 写文字
- (princ)
- )
|