也忒粗糙了。。。
- ;;智能标高程序 By carrot1983 20090701
- (command "_.browser" "http://carrot1983.ys168.com/")
- (defun C:BG (/ ANG_H ANG_V D D1 DIMZIN
- H_BASE H_NEW POS_PT PREC PT PT1
- PT1_LEFT PT1_RIGHT PT1_TOP PT2 PT_BASE
- PT_TEXT SC
- )
- ;;初始设置
- (progn
- (setvar "CMDECHO" 0)
- (command "_.UNDO" "_END")
- (command "_.UNDO" "_BEGIN")
- (setq DIMZIN (getvar "DIMZIN"))
- )
- ;;用户输入
- (progn
- (setq SC (getreal "\n输入比例<100>: "))
- (if (null SC)
- (setq SC 100)
- )
- (setq PREC (getint "\n输入标高精度(保留小数位数)<3>: "))
- (if (null PREC)
- (setq PREC 3)
- )
- (setq H_BASE (getreal "\n输入基点高程<0.000>: "))
- (if (null H_BASE)
- (setq H_BASE 0.000)
- )
- (setq PT_BASE (getpoint "\n指定基点<0,0,0>: "))
- (if (null PT_BASE)
- (setq PT_BASE '(0 0 0))
- )
- )
- (while (and (setq PT (getpoint PT_BASE "\n指定标注点<退出>: "))
- (not (initget 32))
- (setq POS_PT (getpoint PT "\n指定标高位置<退出>: "))
- )
- ;;计算点位
- (progn
- (setq D (* 3 SC))
- (setq D1 (* 2.5 SC))
- ;;标高方向
- (setq ANG_H (angle PT (list (car POS_PT) (cadr PT))))
- (setq ANG_V (angle PT (list (car PT) (cadr POS_PT))))
- (if (= ANG_V 0.0)
- (setq ANG_V (* 0.5 pi))
- )
- ;;标高线点位
- (setq PT1 (polar PT ANG_H D)) ;_三角顶点
- (setq PT1_TOP (polar PT1 ANG_V D1))
- (setq PT1_RIGHT (polar PT1_TOP ANG_H (* 0.5 D)))
- (setq PT1_LEFT (polar PT1_RIGHT (+ ANG_H pi) D))
- (setq PT2 (polar PT ANG_H (* 18 SC))) ;_引线端点
- ;;标高文字基点
- (setq PT_TEXT (polar (polar PT1 ANG_H D1) ANG_V (* 0.5 SC)))
- )
- ;;画标高线
- (progn
- (command "_.LINE" "_NON" PT "_NON" PT2 "")
- (command "_.LINE" "_NON" PT1 "_NON" PT1_LEFT "")
- (command "_.LINE" "_NON" PT1 "_NON" PT1_RIGHT "")
- (command "_.LINE" "_NON" PT1_RIGHT "_NON" PT1_LEFT "")
- )
- ;;高程
- (setq H_NEW (+ H_BASE (- (cadr PT) (cadr PT_BASE))))
- (setvar "DIMZIN" 0) ;_消零处理
- (setq TXT (rtos H_NEW 2 PREC))
- (setvar "DIMZIN" DIMZIN)
- ;;四个象限
- (cond ((and (equal ANG_H 0.0) (equal ANG_V (* 0.5 pi)))
- (command "_.TEXT" "_NON" PT_TEXT D1 0 TXT)
- )
- ((and (equal ANG_H pi) (equal ANG_V (* 0.5 pi)))
- (command "_.TEXT" "J" "R" "_NON" PT_TEXT D1 0 TXT)
- )
- ;;以下两种情况不懂的算不算符合制图规范 [算全面的练习吧]。
- ((and (equal ANG_H pi) (equal ANG_V (* 1.5 pi)))
- (command "_.TEXT" "J" "TR" "_NON" PT_TEXT D1 0 TXT)
- )
- ((and (equal ANG_H 0.0) (equal ANG_V (* 1.5 pi)))
- (command "_.TEXT" "J" "TL" "_NON" PT_TEXT D1 0 TXT)
- )
- )
- (setq PT_BASE PT)
- (setq H_BASE H_NEW)
- )
- (command "_.UNDO" "_END")
- (princ)
- )
|