在CASS中 图面拾取高程点 求累计值 和平均值(原)
本帖最后由 skg123 于 2014-6-19 22:31 编辑本小程序 用于 计算 图面局部高程点平均,
1、选中后会 亮显高程,可以分辨是否已经选择过,避免重复选择,退出后 命令行输入 regen之后亮显消失;
2、程序的漏洞是 空选 就出现错误,将退出;
(defun:pjz()
(setvar "cmdecho" 0) ;指令执行过程不响应
(setq i 0)
(setq zh 0)
(while
(setq en (entsel "\n选择高程点:"))
(setvar "cmdecho" 0)
(redraw (car en) 3);亮显高程点
(setq en_data (entget (car en))) ;取得元体资料列表
(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt
(setq pz (nth 2 pt));提取测量坐标洗z值
(setq pz1 (rtos (nth 2 pt)));提取测量坐标系Z值
(setq i (+ i 1))
(setq zh (+ zh pz))
(setq pj (/ zh i))
(setq sn (rtos i 2 0))
(setq zh1 (rtos zh 2 3))
(setq pj1 (rtos pj 2 3))
(setq pdz (strcat "共拾取" sn "点,高程累计值:" zh1 ",高程平均值: "pj1)) ;输出为数据格式(高程,累计和,平均值)
(princ pdz)
)
)
修改后可以框选了,,借鉴了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)
) 感谢楼主无私奉献,受益匪浅! 谢谢谢谢谢谢学习 支持大师的源代码 学习了测量界的大师啊 不错的东西!!!! (defun c:tt( / i L lst maxx maxy maxZ minx miny minZ pl pjZ sel ss x)
(vl-load-com)
(if (and (setq sel (entsel "\n请选择封闭范围线:"))
(eq (cdr (assoc 0 (entget (car sel)))) "LWPOLYLINE")
(vlax-curve-isClosed (vlax-ename->vla-object (car sel)))
)
(progn
(setq lst(vl-remove-if 'not (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) (entget (car sel)))))
(setq minX (apply 'min (mapcar '(lambda (x) (car x)) lst))
minY (apply 'min (mapcar '(lambda (x) (cadr x)) lst))
maxX (apply 'max (mapcar '(lambda (x) (car x)) lst))
maxY (apply 'max (mapcar '(lambda (x) (cadr x)) lst))
)
(command "zoom" (list minX minY) (list maxX maxY))
(setq ss (ssget "_CP" lst '((0 . "INSERT") (2 . "GC200"))))
(if (and ss (> (sslength ss) 1))
(progn
(setq i 0 L (sslength ss))
(repeat L
(setq pl (cons (caddr (cdr (assoc 10 (entget (ssname ss i))))) pl)
i(1+ i)
)
)
(setq minZ (apply 'min pl)
maxZ (apply 'max pl)
pjZ(/ (apply '+ pl) i)
)
(alert
(strcat
"最大的高程值为:" (rtos maxZ 2 3)
"\n"
"最小的高程值为:" (rtos minZ 2 3)
"\n"
"平均的高程值为:" (rtos pjZ 2 3)
"\n"
"高程值的个数为:" (rtos i 2 0)
)
)
)
(alert "选择的区域范围无高程点!")
)
)
(alert "所选的封闭线不是经量多义线!或 不闭合!")
)
(princ)
)贴个类似的
gzxl 发表于 2014-6-20 11:40 static/image/common/back.gif
贴个类似的
筛选出最大值和最小值,可以借鉴 很好!可用。顶~~~ 框选的不能用 强烈支持,测绘界大师!!! 很好 框选功能很实用cass下
页:
[1]
2