取区域外地形点删除封闭区域内地形点AutoLISP程序源代码

文章介绍了如何在AutoCAD中使用多义线绘制封闭区域,并利用函数删除区域内的地形点,同时从外部数据文件中提取并保留区域外的点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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)
  )
;;区域外地形点生成文件,删除区域内地形点------------------------------------------------------------;;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

测量老覃

感谢您的支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值