本帖最后由 skg123 于 2013-10-26 09:01 编辑
某地形图 高程点如附件中所示,现在要提取高程点坐标值 几千个点,高程非CASS高程。文本的高程为 零 ,有个高程点在文本出入点的位置,带高程值。
操作步骤,首先删除所有高程点的文字,主要只删除文字,保留 “ 点” 然后运行程序 框选所有高程点就可以了。
方案2:删除无关的线,数据,然后运行程序,框选全部,把坐标提取
有兴趣的朋友自己去体会- (defun c:TQZB()
- (princ "\n选择所需输出的点或文字:")
- (setq ss (ssget ));;选取坐标点
- (setq n (sslength ss ));计算坐标点数量
- (setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径
- (setq i 0)
- (repeat n
- (setq spt (ssname ss i ))
- (setq ept (entget spt))
- (if (= (cdr (assoc 0 ept)) )
- (progn
- (setq lxyz (cdr (assoc 10 ept)))
- (setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符
- (setq sy (rtos (nth 0 lxyz)))
- (setq sz (rtos (nth 2 lxyz)))
- (setq i1 (+ i 1));计算点序号
- (setq sn (rtos i1 2 0));将序号实数转换成字符
- (setq sxyz (strcat sn",," sy "," sx "," sz))
- (write-line sxyz ff)
- )
- )
- (setq i (+ i 1))
- );repeat
- )
- (prompt "*提取地图中的高程点坐标值 << 命令:TQZB >> *输出格式(点号,, Y,X,Z)**")
- (prin1)
- (defun c:TQZB()
- (princ "\n选择所需输出的点或文字:")
- (setq ss (ssget ));;选取坐标点
- (setq n (sslength ss ));计算坐标点数量
- (setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径
- (setq i 0)
- (repeat n
- (setq spt (ssname ss i ))
- (setq ept (entget spt))
- (if (= (cdr (assoc 0 ept)) )
- (progn
- (setq lxyz (cdr (assoc 10 ept)))
- (setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符
- (setq sy (rtos (nth 0 lxyz)))
- (setq sz (rtos (nth 2 lxyz)))
- (setq i1 (+ i 1));计算点序号
- (setq sn (rtos i1 2 0));将序号实数转换成字符
- (setq sxyz (strcat sn",," sy "," sx "," sz))
- (princ"\n")
- (prinC sxyz);命令行显示坐标值
- (write-line sxyz ff)
- )
- )
- (setq i (+ i 1))
- );repeat
- (close ff);关闭文件
- )
- (prompt "*提取地图中的高程点坐标值 << 命令:TQZB >> *输出格式(点号,, Y,X,Z)**")
- (prin1)
以下是改进版,可以将桩基的编号读取作为点号- ;;;;读取桩基的编号文本,将编号作为点号
- (defun c:TQWZZB()
- (princ "\n选择所需输出的点(point):")
- (setq ss (ssget ));;选取坐标点
- (setq n (sslength ss ));计算坐标点数量
- (setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径
- (setq i 0)
- (repeat n
- (setq spt (ssname ss i ))
- (setq ept (entget spt))
- (if (= (cdr (assoc 0 ept)) "TEXT")
- (progn
- (setq lxyz (cdr (assoc 10 ept)))
- setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符
- (setq sX11 (rtos sx1 2 3))
- (setq sy (rtos (nth 0 lxyz)2 3))
- (setq sz (rtos (nth 2 lxyz)2 3))
- (setq i1 (+ i 1));计算点序号
- (setq sn (rtos i1 2 0));将序号实数转换成字符
- ;;获取文本内容(编号)做点号
- (setq ent (entget (ssname ss i)))
- (setq typeA (cdr (assoc 1 ent)))
- ;;;;
- (setq sxyz (strcat typeA"," sn "," sy "," sx "," sz))
- (write-line sxyz ff)
- )
- )
- (setq i (+ i 1))
- );repeat
- )
- (prompt "*只适合TEXT点 << 命令:TQWZZB >> *输出格式(点号,, Y,X,Z)**")
- (prin1)
|