明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 562|回复: 4

[讨论] 是(command "erase")bug还是我代码有问题,求各位大神解答

[复制链接]
发表于 2020-11-24 20:38:57 | 显示全部楼层 |阅读模式
小弟最近在写一个处理底图的代码。写到把一些没用的图层、图元分类删除的地方,分类完成了,但在删除的功能时,因为要直接删除选择集(由于图元较多,循环删除选择集内图元耗时太长,故放弃),用了(command "erase")命令,但可以执行第一个command命令,执行第二个command删除命令的时候就报错,不知道是command删除命令有bug还是我的代码不对,求各位大神指导
(defun c:asdf()
  (setq total nil)
  (setq total_group nil)
  (setq dimiden nil)
  (setq dimiden_group nil)
  (setq dote nil)
  (setq dote_group nil)
  (setq dimlead nil)
  (setq dimlead_group nil)
  (setq pubdim nil)
  (setq pubdim_group nil)
  (setq wallsolid nil)
  (setq wallsolid_group nil)
  (setq itm nil)

  (setq total (ssget))
  (foreach itm (vl-remove-if 'listp (mapcar 'cadr (ssnamex total)))
    (or total_group (setq total_group (ssadd)))
    (ssadd itm total_group)
                 )

  (setq dimlead (ssget "P" '((8 . "DIM_LEAD"))))
  (foreach itm (vl-remove-if 'listp (mapcar 'cadr (ssnamex dimlead)))
    (or dimlead_group (setq dimlead_group (ssadd)))
    (ssadd itm dimlead_group)
    (ssdel itm total_group)
                 )

  (command "erase" dimlead "")

  (sssetfirst nil total_group)
  (setq pubdim (ssget "P" '((8 . "PUB_DIM"))))
  (foreach itm (vl-remove-if 'listp (mapcar 'cadr (ssnamex pubdim)))
    (or pubdim_group (setq pubdim_group (ssadd)))
    (ssadd itm pubdim_group)
    (ssdel itm total_group)
                 )

  (command "erase" pubdim "")


  (sssetfirst nil total_group)
  (setq wallsolid (ssget "P" '((8 . "PUB_WALL") (2 . "SOLID"))))
  (foreach itm (vl-remove-if 'listp (mapcar 'cadr (ssnamex wallsolid)))
    (or wallsolid_group (setq wallsolid_group (ssadd)))
    (ssadd itm wallsolid_group)
    (ssdel itm total_group)
                 )

  (command "erase" wallsolid "")



  )

 楼主| 发表于 2020-11-24 22:15:06 | 显示全部楼层
求大佬回复
 楼主| 发表于 2020-11-25 11:07:43 | 显示全部楼层
求大佬帮忙,谢谢各位大佬
发表于 2020-11-25 11:51:10 | 显示全部楼层
思路太绕了,很多语法也不对,看看是不是这样的效果

(defun c:tt5 (/ dimlead pubdim ss wallsolid)
(setq ss (ssget))
(if (setq dimlead (ssget "P" '((8 . "DIM_LEAD")))) (command "erase" dimlead "" "SELECT" ss ""))
(if (setq pubdim (ssget "P" '((8 . "PUB_DIM")))) (command "erase" pubdim "" "SELECT" ss ""))
(if (setq wallsolid (ssget "P" '((8 . "PUB_WALL") (2 . "SOLID")))) (command "erase" wallsolid ""))
(princ)       
)
发表于 2020-11-29 14:05:04 | 显示全部楼层
(while
(cond
  ( (= (cdr  (assoc 8 (entget ...))) "你想删除的。。") (entdel ...)
)

)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-17 16:31 , Processed in 0.227085 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表