当前位置 - 股票行情交易網 - 財經資訊 - CAD中高程點提取橫斷面數據的方法

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 ?0

ctim (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: