;自动标注标高程序
;要求首先输入绘图比例
(defun C:bg0()
(if (= bl nil)(setq bl (getreal "\ninput bl----:")))(setvar "userr1" bl)
(setq pp1 (getpoint "\n标高标注位置:"))
(command "osnap" "int,end,mid,nea,cen,per,tan")
(setq p0 (getpoint "\n基准点:")) (command "osnap" "off")
(setq y (getreal "\n基准点标高值<0.00>"))
(if (= y nil)(setq y 0.00))
(command "osnap" "int,end,mid,nea,cen,per,tan")
(setq p1 (getpoint "标注点:")) (command "osnap" "off")
(while (/= p1 nil)
    (setq xx1 (car pp1) yy1 (cadr pp1))
    (setq xx2 (car p1) yy2 (cadr p1))
    (setq xx0 (car p0) yy0 (cadr p0))
    (setq ddd (- xx2 xx1))
    (setq b1 (- (cadr p1) (cadr p0)))
    (setq bb (+ (* bl b1 0.001) y))
    (setq b2 (rtos bb 2 2))
    (setq b3 (strcat "标高值<" B2 ">:"))
    (setq b3 (getstring b3))
    (if (/= b3 "")(setq b2 b3))
    (setq x1 (car p1) y1 (cadr p1))
    (setq pt1 (list xx1 yy2) pty (+ yy2 3))
    (if (>= ddd 0.00)(progn
      (setq ptx2 (+ xx1 3) ptx3 (- xx1 3) ptx4 (- ptx3 10))
      (setq ppp (list (- ptx3 8) (+ pty 1)))
      (setq ppp1 (polar pt1 0 6) ppp2 (polar pt1 pi 3))
      ))
    (if (< ddd 0.00)(progn
      (setq ptx2 (- xx1 3) ptx3 (+ xx1 3) ptx4 (+ ptx3 10))
      (setq ppp (list ptx3 (+ pty 1)))
      (setq ppp1 (polar pt1 pi 6) ppp2 (polar pt1 0 3))
      ))
    (setq pt2 (list ptx2 pty) pt3 (list ptx3 pty) pt4 (list ptx4 pty))
    (command "pline" pt3 "w" "0" "0" pt1 pt2 pt4 "")
    (command "pline" ppp1 "w" "0" "0" ppp2 "")
    (command "text" ppp "3" "0" b2)
    (command "osnap" "int,end,mid,nea,cen,per,tan")
    (setq p1 (getpoint "标注点:")) (command "osnap" "off")
    )
(command "osnap" "int,end,mid,nea,cen,per,tan")
)
