CAD中高程点提取横断面数据的方法
方法1:结合EXCEL,先用ID命令依次点取各点,之后从命令行选择X,Y,Z坐标数据,导入用EXCEL中计算。
方法2:用lisp编程。大概写了下,边桩数量7个,前4个一组,后3个一组,按你给的格式定的,先选取桩号,然后是中桩,再是边桩,然后是下一组桩号,中桩,边桩,以此类推,源代码:
;;从这里开始往下复制
(defun getinput ()
(setq ss1 (ssget '((0 . "TEXT,MTEXT")))tt ?(entget (ssname ss1 0))
ttt (cdr (assoc 1 tt))
aa ?(getpoint "\n点取中桩点:")
ax ?(car aa)
ay ?(cadr aa)
az ?(caddr aa)
bb ?(getpoint "\n点取第一个边桩点:")
bx ?(car bb)
by ?(cadr bb)
bz ?(caddr bb)
bzz (abs (- bz az))
bl ?(sqrt (- (expt (distance aa bb) 2) (expt bzz 2)))
cc ?(getpoint "\n点取第二个边桩点:")
cx ?(car cc)
cy ?(cadr cc)
cz ?(caddr cc)
czz (abs (- cz az))
cl ?(sqrt (- (expt (distance aa cc) 2) (expt czz 2)))
dd ?(getpoint "\n点取第三个边桩点:")
dx ?(car dd)
dy ?(cadr dd)
dz ?(caddr dd)
dzz (abs (- dz az))
dl ?(sqrt (- (expt (distance aa dd) 2) (expt dzz 2)))
ee ?(getpoint "\n点取边第四个桩点:")
ex ?(car ee)
ey ?(cadr ee)
ez ?(caddr ee)
ezz (abs (- ez az))
el ?(sqrt (- (expt (distance aa ee) 2) (expt ezz 2)))
ff ?(getpoint "\n点取另一侧第一个边桩点:")
fx ?(car ff)
fy ?(cadr ff)
fz ?(caddr ff)
fzz (abs (- fz az))
fl ?(sqrt (- (expt (distance aa ff) 2) (expt fzz 2)))
gg ?(getpoint "\n点取另一侧第二个边桩点:")
gx ?(car gg)
gy ?(cadr gg)
gz ?(caddr gg)
gzz (abs (- gz az))
gl ?(sqrt (- (expt (distance aa gg) 2) (expt gzz 2)))
hh ?(getpoint "\n点取另一侧第三个边桩点:\n")
hx ?(car hh)
hy ?(cadr hh)
hz ?(caddr hh)
hzz (abs (- hz az))
hl ?(sqrt (- (expt (distance aa hh) 2) (expt hzz 2)))
) (list(cons 10 bl)
(cons 11 bzz)
(cons 12 cl)
(cons 13 czz)
(cons 14 dl)
(cons 15 dzz)
(cons 16 el)
(cons 17 ezz)
(cons 18 fl)
(cons 19 fzz)
(cons 20 gl)
(cons 21 gzz)
(cons 22 hl)
(cons 23 hzz)
(cons 24 ttt)
))
(defun c:hdm ()
(setq num ?0ctim (menucmd "M=$(edtime,$(getvar,date),H:MM:MM)")
) (write-file"d:\\横断面数据.txt"
"\n*********************************\n"
) (write-file "d:\\横断面数据.txt" "*****") (write-file "d:\\横断面数据.txt" ctim) (write-file "d:\\横断面数据.txt" "*****\n") (write-file"d:\\横断面数据.txt"
"*********************************\n"
) (while (>= num 0)(setq data (getinput)
?bl ? (cdr (assoc 10 data))
?bzz ?(cdr (assoc 11 data))
?cl ? (cdr (assoc 12 data))
?czz ?(cdr (assoc 13 data))
?dl ? (cdr (assoc 14 data))
?dzz ?(cdr (assoc 15 data))
?el ? (cdr (assoc 16 data))
?ezz ?(cdr (assoc 17 data))
?fl ? (cdr (assoc 18 data))
?fzz ?(cdr (assoc 19 data))
?gl ? (cdr (assoc 20 data))
?gzz ?(cdr (assoc 21 data))
?hl ? (cdr (assoc 22 data))
?hzz ?(cdr (assoc 23 data))
?ttt ?(cdr (assoc 24 data))
)
(if (/= ttt "")
? (progn
(write-file "d:\\横断面数据.txt" ttt)
(write-file "d:\\横断面数据.txt" "\n")
? )
)
(if (not ttt)
? (
(write-file "d:\\横断面数据.txt" "桩号缺失!\n")
? )
)
(setq num (+ num 1))
(write-file "d:\\横断面数据.txt" (rtos num 2 0))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos bl 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos bzz 2 4))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos cl 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos czz 2 4))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos dl 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos dzz 2 4))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos el 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos ezz 2 4))
(write-file "d:\\横断面数据.txt" "\n")
(setq num (+ num 1))
(write-file "d:\\横断面数据.txt" (rtos num 2 0))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos fl 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos fzz 2 4))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos gl 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos gzz 2 4))
(write-file "d:\\横断面数据.txt" " ?")
(write-file "d:\\横断面数据.txt" (rtos hl 2 4))
(write-file "d:\\横断面数据.txt" " ? ")
(write-file "d:\\横断面数据.txt" (rtos hzz 2 4))
(write-file "d:\\横断面数据.txt" "\n\n")
))
(defun write-file (filename content)
(setq stream (open filename "a") ) (princ content stream) (close stream))
;;复制到这一行为止
把上面源代码存入写字板内,另存成XX.LSP,
CAD-->工具-->加载应用程序-->选XX.LSP-->确定。
命令行输入hdm开始执行;看命令行提示。最后在D:\横断面数据.tx内输出结果如下样式,我CAD里的图形没有Z坐标高差所以高差都为0: