- 积分
- 83
- 明经币
- 个
- 注册时间
- 2011-3-19
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
;标注导线方位角及距离程序
(defun c:bzfwj();标注导线方位角及距离程序
(setq thzt (getvar "textsize"))
(setq hzt (getdist (strcat "\n 字体高度<" (rtos thzt) ">:")))
(if (= hzt nil) (setq hzt thzt))
(setvar "dimscale" hzt)
(command "style" "big" "宋体" hzt 1 "" "n" "")
(princ "\n 请选择要标注的线:")
(setq ssl (ssget))
(setvar "osmode" 0) ;关闭捕捉
(setq ns (sslength ssl))
(setq is 0)
(repeat ns
(setq sl (entget (ssname ssl is )))
(setq n (length sl))
(setq i 0)
(setq xal nil)
(if (= (cdr (assoc 0 sl)) "LWPOLYLINE")
(progn
(repeat n
(setq tal (nth i sl))
(setq ftal (nth 0 tal))
(if (= ftal 10) (setq xal (cons (list (nth 1 tal)(nth 2 tal)) xal)))
(setq i (+ i 1))
(princ ftal)
);repeat
(setq xal (reverse xal))
(setq n (length xal))
(if (> n 1)
(progn
(setq i 0)
(repeat (- n 1)
(setq p1 (nth i xal))
(setq p2 (nth (+ i 1) xal))
(setq x1 (nth 0 p1))
(setq x2 (nth 0 p2))
(setq y1 (nth 1 p1))
(setq y2 (nth 1 p2))
(setq ss (distance p1 p2))
(setq aa (angle p1 p2))
(setq pmid (list (/ (+ x1 x2) 2) (/ (+ y1 y2) 2)))
(command "text" "s" "big" "j" "bc" pmid (/ (* aa 180) 3.1415926) (dmstosdms ( hdtodms (jsfwj y1 x1 y2 x2))) "")
(command "text" "s" "big" "j" "tc" pmid (/ (* aa 180) 3.1415926) (rtos ss 2 3) "")
(setq i (+ i 1))
);repeat
);progn
);if
);progn
);if
(if (= (cdr (assoc 0 sl)) "LINE")
(progn
(setq p1 (cdr (assoc 10 sl)))
(setq p2 (cdr (assoc 11 sl)))
(setq x1 (nth 0 p1))
(setq x2 (nth 0 p2))
(setq y1 (nth 1 p1))
(setq y2 (nth 1 p2))
(setq ss (distance p1 p2))
(setq aa (angle p1 p2))
(setq pmid (list (/ (+ x1 x2) 2) (/ (+ y1 y2) 2)))
(command "text" "s" "big" "j" "bc" pmid (/ (* aa 180) 3.1415926) (dmstosdms ( hdtodms (jsfwj y1 x1 y2 x2))) "")
(command "text" "s" "big" "j" "tc" pmid (/ (* aa 180) 3.1415926) (rtos ss 2 3) "")
);progn
);if
(setq is (+ is 1))
);repeat
)
(defun dmstosdms(dms)
(setq d (fix dms))
(setq m (fix (* 100.0 (- dms d))) )
(setq s (* (- (* 100.0 (- dms d)) m) 100.0) )
(if (>= s 60.0) (progn (- s 60.0) (+ m 1)))
(if (>= m 60.0) (progn (- m 60.0) (+ d 1)))
(strcat (rtos (fix d)2 0) "°" (rtos (fix m)2 0) "′" (rtos s 2 1) "″")
)
(defun hdtodms(tjd)
(setq jd tjd)
(setq bneg 1)
(if (< jd 0) (setq bneg -1))
(setq jd (abs (/ (* tjd 180.0) 3.1415926)))
(setq du (fix jd))
(setq fen (fix (* (- jd du) 60.0)))
(setq miao (* (- (* (- jd du) 60.0) fen) 60.0) )
(if (< (abs (- miao 60)) 0.0001)
(progn
(setq miao 0.0)
(setq fen (+ fen 1))
(if (< (abs (- fen 60)) 0.0001)
(progn
(setq fen 0.0)
(setq du (+ du 1))
)
)
)
)
(setq dms (* bneg (+ du (/ fen 100.0) (/ miao 10000.0))))
)
(defun jsfwj(tx1 ty1 tx2 ty2)
(setq dx (- tx2 tx1) dy (- ty2 ty1))
(if (= dx 0)
(progn
(if (> dy 0) (setq fwj (/ 3.1415926 2)))
(if (< dy 0) (setq fwj (* 3 (/ 3.1415926 2))))
)
(setq fwj (+ (atan (/ dy dx)) (/ 3.1415926 2) (* (/ -3.1415926 2) (/ (abs dx) dx))))
)
(if (< fwj 0) (setq fwj (+ fwj (* 3.1415926 2))) (setq fwj fwj))
)
|
|