 - ;;取两点Y坐标差通用函数
- (defun szx_h (a b)
- (setq h (abs (- (cadr a) (cadr b))))
- (atof (rtos h 2 3))
- )
- (defun c:tt (/ pt1 pt2 old_cmd cl ortho ww hh1 ang pt3 hh hh2 str bg)
- ;;保存系统变量设置
- (setq old_CMD (getvar "CMDECHO")) ;_取得变量值
- (setq cl (getvar "clayer"))
- (setvar "CMDECHO" 0)
- (setq ortho (getvar "orthomode")) ;_取得变量值
- (setvar "orthomode" 0) ;_关
- (setq ww (getvar "dimzin"))
- (setvar "dimzin" 1)
- (if (not (tblsearch "layer" "标高"))
- (command "-layer" "m" "标高" "c" "3" "" "")
- )
- (setvar "clayer" "标高")
- (setq pt1 (getpoint "\n标高基准点:"))
- (if (not (setq hh1 (getreal "\n请输入基准点标高±0.000:")))
- (setq hh1 0.000)
- )
- (setq hh1 (if (/= hh1 0)
- (rtos hh1 2 3)
- "%%P0.000"
- )
- )
- (while (setq pt2 (getpoint pt1 "\n定位点:"))
- (setq ang (angle pt1 pt2))
- (setq pt3 (polar pt2 0 100))
- (setq hh (szx_h pt1 pt2)
- hh2 (/ hh 1000)
- )
- (if (/= (type hh1) 'str)
- (setq hh1 (vl-princ-to-string hh1))
- ) ;判断是否是字符串并转换
- (setq hh1 (atof hh1)) ;字符串转换成实型数
- (if (and (> ang 0) (< ang 3.141))
- (setq str (+ hh1 hh2))
- (setq str (- hh1 hh2))
- )
- (setq str (if (/= str 0)
- (rtos str 2 3)
- "%%P0.000"
- )
- )
- (if (and (> ang 1.570) (< ang 4.712))
- (command "._insert" "bgz.dwg" "non" pt2 "" "" str)
- (command "._insert" "bgy.dwg" "non" pt2 "" "" str)
- )
- (setq bg (entlast))
- (initget "Yes No")
- (if (= "Yes"
- (getkword "\n是否镜像?[是(Y)/否(N)] <N>:")
- )
- (command "mirror" bg "" "non" pt2 "non" pt3 "y")
- )
- (setvar "orthomode" 1) ;_开
- (command "_move" bg "" pt2 pause)
- (setvar "orthomode" 0);_关
- )
- ;;刷新图形窗口
- (redraw)
- (setvar "CMDECHO" old_CMD)
- (setvar "orthomode" ortho) ;_恢复变量
- (setvar "dimzin" ww)
- (setvar "clayer" cl)
- (princ)
- )
网上找的标高标注程序,用起来都不顺手,自己写了一个,有需要的来去用
|