1 概述
2
2 .1
2
2 .1
2 .2
(1) 初始地形图处理
(defunc:pltol()
;LWPOLYLINE转化为
(setqn 0)
(setqsh (sslength e))
(if e
(while (< n sh)
(setq e1 (ssname e n))
(command "pedit" e1 "d" "")
(setq x (entget e1))
(setq ngc (atof (setq la (fld 8 x))))
(command "explode" e1)
(setq n (+ n 1))
) ) )
(defun fld(num lst)
(cdr (assoc num lst))
)
(defunc:spltol ()
;SPLINE转化为
(setqn 0)
(setqe (ssget "X" (list (cons 0 "SPLINE"))))
(setqsh (sslength e))
(if e
(while (< n sh)
(setq x (entget (setq e1 (ssname e n))))
(setq nla (itoa (fix (caddr (fld 10 x)))))
(if (= (fld 0 x) "SPLINE")
(progn
(command "layer" "n" nla "c"
(command"line")
(setq nm (length x)
dzs (fld 73 x) dzs1 (fld 74 x))
(while (> nm 5)
(if (= (car (nth nm x)) 10)
(progn
(setq b1 (nth nm x))
(setqx1 (cadr b1))
(setqy1 (caddr b1))
(setqz1 (cadddr b1))
(setqglb (list x1 y1))
(commandglb)
) )
(setq nm (- nm 1))
)))
(command "")
(setq n (+ n 1))
)))
(defundxtent1 ()
(setqn 0 xdzb nil)
(setqxds 0)
(setqsh (sslength e1))
(while (< n sh)
(setq x (entget (ssname e1 n)))
(if (= (fld 0 x) "LINE")
(progn
(setqdxtgcgc (fld 8 x))
(setqdxtgcgc (atoi dxtgcgc))
(if(> dxtgcgc 10)
(progn
(setq pst (fld 10 x))
(setq pet (fld 11 x))
(setq zb (list gc
(list (car pst) (cadr pst))
(list (car pet) (cadr pet))
))
(setq xdzb (cons zb xdzb))
(setq xds (+ xds 1))
))))
(setq n (+ n 1))
))
(defunc:dxtsec ()
(setqpmh (+ pmh 1))
(setqpmh (getstring "n 剖面号
(setqpt1 (getpoint "n 剖切位置起点
(setqpt2 (getpoint pt1 "n 剖切位置终点
(setqpt3 (getpoint "n 剖面图布置
(setqp01 pt3)
(setqe1 (ssget "F" (list pt1 pt2)));利用AutoCAD的目标选择“F”方式选取与剖切线相交的地形线。
(dxtent);获取与剖切线相交地形线的坐标
(setqmxgc -100)
(setqmngc 10000)
(setqm 0 pmp nil)
(setqn xds i 0)
(while (< i n)
(setq crosp
(inters pt1 pt2 (nth 1 (nth ixdzb)) (nth 2 (nth i xdzb)) 1)
);求剖切线与地形线的交点
(if (/= crosp nil)
(progn
(setqdxtgcgc (nth 0 (nth i xdzb)))
(setqmxgc (max mxgc dxtgcgc))
(setqmngc (min mngc dxtgcgc))
(setqdst (distance pt1 crosp));剖切线起点与交点的距离
(setqdst (* (/ blcz dxthtbl) dst))
(setqpmp (cons (list m dst dxtgcgc) pmp))
(setqm (+ m 1))
))
(setq i (+ i 1))
))
(defunC:mtab()
(setqtb1 nil tb2 nil tb3 nil)
(setqrows (getint "表格行数
(setqcols (getint "表格列数
(setqrowh (getreal "行高
(setqcolw (getreal "列宽
(setqp1 (getpoint "n表格左上角点位置
(command"pline" p1 "w" "0.5" "0.5"
(setqp2 (list (+ (car p1) (* cols colw)) (cadr p1)))
(setqp4 (list (car p2) (- (cadr p2) (* rows rowh))))
(setqp3 (list (car p1) (- (cadr p2) (* rows rowh))))
"C" )
(setqn 1)
(while(< n rows);绘水平线表格
(command "pline" (list (car p1) (- (cadrp1) (* n rowh))) "w" "0" "0"
(list (car p2) (- (cadr p2) (* rowh n))) "")
(setq n (+ n 1))
)
(setqn 1)
(while(< n cols) ;绘垂直表格线
(command"pline" (list (+ (car p1) (* n colw)) (cadr p1)) "w""0" "0" (list (+ (car p1) (* n colw)) (cadr p3))
"")
(setq n (+ n 1))
)
(command"text" "m" (list (+ (car p1) (* 0.5 cols colw))
(+(cadr p1) 5)) "3" "0" "TITLE" )
(setq n 0)
(while(< n rows)
(setq m 0)
(while (< m cols)
(cond
((< m 26) (setq bzstr (chr (+ 65 m))))
((>= m 26) (setq bzstr (strcat (chr (+ 64 (/ m 26))) (chr (+ 65 (- m (* 26(/ m 26))))))))
)
(command "text""m" (list (+ (car p1) (* 0.5 colw) (* m colw))
(- (cadr p1) (* 0.5 rowh) (* nrowh)))
(getvar"TEXTSIZE") "0" (strcat bzstr (itoa (+ n 1))))
(setq m (+ m 1))
)
(setqn (+ n 1))
))

(defunentsgc()
(setqn 0)
(while(< n sh) (setq x (entget (ssname e1 n)))
(if (=(fld 0 x) "TEXT")
(progn
(setq agc (fld 1 x))
(setq c (substr agc 1 1))
(if (or (= c "+") (= c "-") (and (>= c "0")(<= c "9")))
(progn
(if (or (= c "+") (= c "-"))
(setq bgc (substr agc 2))
(setq bgc agc)
)
(setq cgc (atof bgc))
(setq zh (rtos cgc 2 gcws))
(setq x (subst (cons 1 zh) (assoc 1 x) x))
(entmod x)
)
))
))
(setq n (+ n1)))
)
(defunc:yxws()
(setqe1 (ssget))
(setvar "dimzin" 0)
(setqgcws (getint "保留小数位数
(ife1 (entsgc) (print "n not found"))
(setqx nil)
)
(defunc:seepmesh()
(iffn
(setqfn (getfiled "渗流结果文件名
(setqfn (getfiled "渗流结果文件名
(setqf (open fn "r"))
(setqmd (read-line f))
(while (/= (substr md 25 8) "单元总数")
(setq md (read-line f))
)
(setqdyzs (atoi (substr md 58 5)));读单元总数
(setqmd (read-line f))
(setqjdzs (atoi (substr md 58 5)));读节点总数
(setqmd (read-line f))
(setqclh (atoi (substr md 58 5)));读材料总数
(setqm 0)
(repeat clh
(setq m (+ 1 m))
(setq tcm (strcat "zclh" (itoa m)))
(command "layer" "m" tcm "c" (itoa m) tcm"")
)
(setqm 0 n 0)
(repeatdyzs;对单元循环,
(setqm (+ m 1))
(setqclh (nth 0 (nth m dycfb)))
(setqjdh1 (nth 1 (nth m dycfb)))
(setqjdh2 (nth 2 (nth m dycfb)))
(setqjdh3 (nth 3 (nth m dycfb)))
(setqjdh4 (nth 4 (nth m dycfb)))
(command "layer" "s" (strcat "zclh" (itoa clh))"")
(command"pline";绘制单元网格
(nth jdh1 jdzbb)
(nth jdh2 jdzbb)
(nth jdh3 jdzbb)
(nthjdh4 jdzbb) "c")
(setqbzdzb (mapcar '+ (nth jdh1 jdzbb) (nth jdh2 jdzbb)
(nthjdh3 jdzbb) (nth jdh4 jdzbb)))
(setqbzdzb (list (/ (car bzdzb) 4.0) (/ (cadr bzdzb) 4.0)))
(command "text" "m" bzdzb "0.5" "0"(itoa m))
;标注单元号
(setqm 0)
(repeatjdzs
(setq m (+ m1))
(setq bzdzb (nth m jdzbb))
(setq bzdzb (list (+ (car bzdzb) 0.0) (+ (cadr bzdzb) 0.0)))
(command "text" "m" bzdzb "0.5" "0"(itoam))
))
(closef)
)
作者简介
耿振云 男