- (vl-load-com)
- (vl-load-com)
- (defun c:zhcx (/ en old_lay a e perpt pt0 obj len ang leng leng1 leng2 pt1 pt2 str_1 str_2 px py pxy nn1 nn2 pt);桩号查询
- (prompt "2010-07-27 zo roo CGGC 武赤公路")
- (prompt "*查询线路任意点桩号* << C:zhcx>> *计算中桩坐标*")
- (setq old_lay (getvar "clayer"))
- (if (=(tblobjname "LAYER" "桩号标注") nil)
- (progn
- (entmake (list
- '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- '(6 . "CONTINUOUS")
- '(62 . 3)
- '(70 . 0)
- (cons 2 "桩号标注")
- )
- )
- )
- )
- (setvar "clayer" "桩号标注")
- (setq en (entsel "\n选择道路中心线: ")
- a (getreal "\n请输入起点桩号:")
- e (car en)
- pt (cadr en)
- )
- (if (setq len 2.000) ;此处要加入非法输入的控制
- (progn
- (setq OBJ (vlax-ename->vla-object (car en)))
- )
- )
- (while (setq pt0 (getPoint "\n选择查询点:"))
- ;画曲线的垂线
- (setq Perpt (vlax-curve-getClosestPointTo OBJ pt0 T)
- LST (vlax-curve-getfirstderiv OBJ (vlax-curve-getparamatpoint OBJ Perpt))
- ANG (atan (/ (cadr LST) (car LST)))
- pt1 (polar Perpt (+ ANG (* 0.5 pi)) len)
- pt2 (polar Perpt (- ANG (* 0.5 pi)) len)
- ;此处就是你画出来的是水平线的原因,变量换个方向即可
- )
- (setq ang2 (angtos (angle pt1 pt2 )0 4) )
- (command "pline" pt0 perpt "")
- ;计算桩号
- (setq leng (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))
- leng1 (+ a (vlax-curve-getDistAtPoint e Perpt))
- leng2 (- leng leng1)
- )
- ;计算桩号
- (if (< leng1 0.0) (setq fh "-") (setq fh "+"))
- (setq nn1 (fix (/ leng1 1000.0 )))
- (setq nn2 (abs(- leng1 (* 1000.0 nn1 ))))
- (if (= nn2 0.0) (setq str_1 (strcat fh "00" )))
- (if (and (> nn2 0) (< nn2 10.0)) (setq str_1 (strcat (strcat fh "00" ) (rtos nn2 2 3))))
- (if (and (> nn2 10.0) (< nn2 100.0)) (setq str_1 (strcat (strcat fh "0" ) (rtos nn2 2 3))))
- (if (>= nn2 100.0) (setq str_1 (strcat fh (rtos nn2 2 3))))
-
- (setq str_1 (strcat "K"(rtos nn1 2 0)"+" (rtos nn2 2 3) ))
- (setq str_2 (strcat "距离:"(rtos (distance pt0 perpt) 2 3) ))
-
- (setq pt4 (polar pt1 (+ (* pi 0.45) ang) (* -2 (* 1.65406 0.67))))
- (command "text" "j" "MC" pt0 "0.3" ang2 str_1)
-
- (command "text" "j" "MC" (polar pt0 (+ (* pi 2) ang) (* -0.5 (* 1.65406 0.67))) "0.3" ang2 str_2)
-
- (setq py (rtos (nth 0 pt0)));提取测量坐标系Y值
- (setq px (rtos (nth 1 pt0)));提取测量坐标洗X值
- (setq pxy (strcat str_1"中桩坐标:X="px",Y="py))
- (princ pxy)
- )
- (princ)
- )
- ;(vlax-curve-getClosestPointTo (vlax-ename->vla-object (car (entsel))) (getpoint) T)
|