修改后可以框选了,,借鉴了http://bbs.mjtd.com/thread-85363-1-1.html 中 的代码- (defun c:pjz(/ p1 p2 ss sn si i x y e fw)
- (prompt "**从CASS中提取高程点计算高程累计和 和平均数,请在命令行输入 pjz **")
- (setq sn 0)
- (setq zh 0)
- (setq ss(ssget (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))
- ;=====计算平均值==============
- (setq pz (nth 2 pt));提取测量坐标洗z值
- (setq pz1 (rtos (nth 2 pt)));提取测量坐标系Z值
- (setq zh (+ zh pz))
- (setq pj (/ zh i))
- (setq si (rtos i 2 0))
- (setq zh1 (rtos zh 2 3))
- (setq pj1 (rtos pj 2 3))
- (setq pdz (strcat "本次共拾取" si "点,高程累计值:" zh1 ",高程平均值: "pj1 ",坐标文件在D盘;")) ;输出为数据格式(高程,累计和,平均值)
- )
- (close fw)
- ))
- (princ pdz)
- )
|