本帖最后由 Student 于 2011-2-17 09:12 编辑
下面是一个简单的代码:
;-------------------------------------------------------------------------------------------
;提取cass中的高程点->Dat文件
(defun c:b2d(/ p1 p2 ss sn si i x y e fw) (setq sn 0) (setq p1(getpoint "\n拾取选择框的一个角点:")) (if p1 (setq p2(getcorner p1 "\n选择对角点:")) ) (if p2 (setq ss(ssget "c" p1 p2 (list(cons 8 "GCD")(cons 2 "GC200")))) ) (if ss(progn (setq fw(open "d:\\ex.dat" "w")) (setq sn(sslength ss)) (setq i 0) (while(< i sn) (setq si(ssname ss i)) (setq pt(cdr(assoc 10 (entget si)))) (setq x(rtos(car pt)2 3) y(rtos(cadr pt)2 3) e(rtos(caddr pt)2 3)) (princ(strcat (itoa (1+ i))",GCD," x "," y "," e "\n") fw) (setq i(1+ i)) ) (close fw) (alert "OK") )) (princ) ) ;-------------------------------------------------------------------------------------
本代码并未优化、只供参考。
下面是测试结果:
1,GCD,1631.769,448.348,199.598 2,GCD,1636.579,445.412,197.584 3,GCD,1640.756,446.087,197.533 4,GCD,1642.382,446.844,197.705 5,GCD,1646.092,447.788,197.663 6,GCD,1670.749,443.778,198.698 7,GCD,1669.312,442.277,199.154 8,GCD,1667.745,441.424,199.123 9,GCD,1665.839,440.279,199.200
|