本帖最后由 changyiran 于 2012-4-24 20:26 编辑
czc520hx 发表于 2012-4-24 09:29
,,,急急急
- (defun c:tt( / EL1 EL2 F F1 GCB GCZ JZGC LCB LCGC LCGCB N V1 V2 V3 WJM YGCZ)
- (command"undo""m")
- (setq v1(getvar"osmode"))
- (setq v2(getvar"cmdecho"))
- (setq v3(getvar"blipmode"))
- (setq v4(getvar"dimzin"));保存控制对主单位值的消零处理的当前值
- (setvar"blipmode"0)
- (setvar"cmdecho"0)
- (setvar "osmode"0)
- (setvar"dimzin"0);保留小数位数时如果位数不足可以补零
- (setq f(getfiled"请选择数据文件""""dmt"0))
- (setq f1(open f "r")n 0)
- (setq wjm(read-line f1)lcb'()gcb'()jzgc 0)
- (while wjm
- (while(vl-string-search","(if(setq lcgc(read-line f1))lcgc "tcb"));如果是nil就退出吧
- (setq lcgcb(read(strcat"("(thdh lcgc)")")));获得里程高程表
- (setq ygcz(cadr lcgcb));保存原高程表
- (setq lcgcb(list (car lcgcb)(+ (cadr lcgcb)jzgc 60)));获得增加基准高程后的里程高程表
- (entmake(list'(0 . "line")(list 10 (car lcgcb)(+ 60 jzgc))(list 11 (car lcgcb)(cadr lcgcb))));生成竖线
- (entmake(list'(0 . "text")(cons 1 (rtos ygcz 2 3))'(40 . 2)(list 10 (-(car lcgcb)6.33333)(+ 70 jzgc))));高程值注记
- (entmake(list'(0 . "text")(cons 1 (rtos (car lcgcb) 2 3))'(40 . 2)(list 10 (-(car lcgcb)6.33333)(+ jzgc 50))));里程点注记
- (setq lcb(cons(list 10(car lcgcb)(+ 60 jzgc))lcb))
- (setq gcb(cons (cons 10 lcgcb) gcb))
- (setq gcz(cons (cadr lcgcb)gcz))
- (setq n(1+ n));计算里程点数
- )
- (setq el1(append(list'(0 . "LWPOLYLINE")'(100 . "AcDbEntity")'(100 . "AcDbPolyline"))(list(cons 90 n)) lcb ));里程图元表
- (setq el2(append(list'(0 . "LWPOLYLINE")'(100 . "AcDbEntity")'(100 . "AcDbPolyline"))(list(cons 90 n)) gcb ));高程图元表
- (setq el3(append(list'(0 . "text")(cons 1 wjm)'(40 . 10)(list 10 (-(/ (cadr(car lcb))2)6.33333)(+ jzgc 30)))));剖面线名图元表
- (entmake el1);生成里程线
- (entmake el2);生成高程线
- (entmake el3);生成剖面线名
- (setq wjm lcgc lcb'()gcb'()n 0 jzgc(apply'max gcz))
- )
- (close f1)
- (setvar "osmode"v1)
- (setvar"cmdecho"v2)
- (setvar"blipmode"v3)
- (setvar"dimzin"v4)
- (alert"运行完毕")
- )
记得每个里程数据的第一行为其名字
学习重要,不能只求源代码
|