|
50铜板
标注平面图上N条直线(线段)方位角、长度的插件 在最好自动生成表格 附一个原代码帮忙看看啊 高手来 线 长 和 方 位 角 瓦 斯 钻 孔 用
(defun c:jlfwj (/ aa ftal hzt i is m n ns p1 p2 pmid sl ss ssl tal thzt x1 x2 xal y1 y2)
(setvar "cmdecho" 0)
(setq thzt (getvar "textsize"))
(if (null mosbak)
(setq mosbak 1)
)
(if (setq m (getint (strcat "\n 要标注[1.线长和方位角/2.线长/3.方位角]:<" (itoa mosbak) ">")))
(setq mosbak m)
)
(setq hzt (getdist (strcat "\n 字体高度<" (rtos thzt) ">:")))
(if (= hzt nil)
(setq hzt thzt)
)
(command ".UNDO" "BE")
(setvar "dimscale" hzt)
(command "style" "big" "宋体" hzt 1 "" "n" "")
(princ "\n 请选择要标注的线:")
(setq ssl (ssget))
(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))
) ; 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)))
(if (or
(= mosbak 1)
(= mosbak 3)
)
(command "text" "s" "big" "j" "bc" pmid (/ (* aa 180) 3.1415926) (dmstosdms (hdtodms (jsfwj y1 x1 y2 x2))))
)
(if (or
(= mosbak 1)
(= mosbak 2)
)
(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)))
(if (or
(= mosbak 1)
(= mosbak 3)
)
(command "text" "s" "big" "j" "bc" pmid (/ (* aa 180) 3.1415926) (dmstosdms (hdtodms (jsfwj y1 x1 y2 x2))))
)
(if (or
(= mosbak 1)
(= mosbak 2)
)
(command "text" "s" "big" "j" "tc" pmid (/ (* aa 180) 3.1415926) (rtos ss 2 3))
)
) ; progn
) ; if
(setq is (+ is 1))
) ; repeat
(command ".UNDO" "E")
(princ)
)
(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)) "°" (rtos (fix m)) "′" (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)
)
)
|
|