在AutoCAD中用多义线绘制一封闭区域,用以下扩展命令将对应的地形数据文件(.dat)中该区域内(稍加修改可变为区域外)的点删除。
;;区域外地形点生成文件,删除区域内地形点------------------------------------------------------------;;
(defun C:zzQywdx
(/ ptName ptSign ptE ptN ptH ptCount filename1 filename2)
(princ
"功能:删除指定区域内的点,取区域外的地形点。(C)QinDong 2017.05 qindxyz@139.com\n"
)
(setq filename1
(getfiled "提示字符串"
"D:\\"
"dat"
2
)
)
(if filename1
(progn
(setq
filename2 (strcat (car (splitx filename1 ".dat"))
"-区域外提取-"
(date)
"-"
(time)
".dat"
)
)
(setq regionObj (entsel))
(setq f1 (open filename1 "r"))
(if (and f1 regionObj)
(progn
(setq f2 (open filename2 "w"))
(setq rIndex 0)
(setq ptCount 0)
(while (setq lineStr (read-line f1))
(setq lineStrs (splitX lineStr ","))
(setq ptName (cons (nth 0 lineStrs) ptName))
;;将点编号或点名生成表
(setq ptE (cons (nth 2 lineStrs) ptE))
;;将E生成表
(setq ptN (cons (nth 3 lineStrs) ptN))
;;将N生成表
(setq ptH (cons (nth 4 lineStrs) ptH))
;;将H生成表
(setq ptSign (cons (itoa rIndex) ptSign))
;;生成记号表
(setq rIndex (+ rIndex 1))
)
(setq ptName (reverse ptName))
;;反序
(setq ptSign (reverse ptSign))
;;反序
(setq ptE (reverse ptE))
;;反序
(setq ptN (reverse ptN))
;;反序
(setq ptH (reverse ptH))
;;反序
(close f1)
;;表处理
(setq rIndex 0)
(while (setq tmpPtname (nth rIndex ptName))
(setq tmpE (nth rIndex ptE))
(setq tmpN (nth rIndex ptN))
(setq tmpH (nth rIndex ptH))
(setq tmpSign (nth rIndex ptSign))
(if
(not (pt_inorout
regionObj
(list (atof tmpE) (atof tmpN)))
)
(progn
(write-line
(strcat tmpPtname ",," tmpE "," tmpN "," tmpH)
f2
)
(setq ptCount (+ 1 ptCount))
)
)
(setq rIndex (+ rIndex 1))
)
;;表处理
(princ
(strcat
"共提取"
(itoa ptCount)
"个点。(C)QinDong 2017.05 qindxyz@139.com\n"
)
)
;;(princ "\n")
(close f2)
)
;;End progn
(princ
"用户取消操作!(C)QinDong 2017.05 qindxyz@139.com\n"
)
)
;;end if
)
;; end progn1
(princ
"用户取消操作!(C)QinDong 2017.05 qindxyz@139.com\n"
)
)
;;end if1
(princ)
)
;;区域外地形点生成文件,删除区域内地形点------------------------------------------------------------;;