怎样合并两个选择集?
<p>例如我向把S1 选择集和S2选择集合并成S3 </p><p>该怎么表达?</p><p>用到什么函数?</p> ygp820601 发表于 2012-12-18 21:00 static/image/common/back.gif呵呵,求差集的函数有问题,当两个选择集相同时,差集应该为nil,这种情况没有考虑到。
(defun ssinter (ss ...
这位朋友写的代码有很多问题呀,我重改了一个
(defun ssunion (SS1 SS2 / n);求两个选择集的并集
(cond
((and (equal ss1 nil) (not (equal ss2 nil))) ss2)
((and (equal ss2 nil) (not (equal ss1 nil))) ss1)
((and (equal ss1 nil) (equal ss2 nil)) nil)
(
(and (not(equal ss2 nil))(not (equal ss1 nil)))
(progn
(setq n 0)
(repeat (sslength ss2)
(if (not(ssmemb (ssname ss2 n) ss1))
(setq ss1 (ssadd (ssname ss2 n) ss1))
)
(setq n (1+ n))
)
ss1
)
)
)
) yjtdkj 发表于 2013-12-14 17:07
这位朋友写的代码有很多问题呀,我重改了一个
感谢代码,取走用了 去查查XYP1964的函数! 本帖最后由 作者 于 2007-8-6 8:26:20 编辑 <br /><br /> <p>(setq s3 (ssadd ename s1))</p><p>ename是s2的实体,当然这个s2的实体要做循环的</p><p>分别取出S2中的实体,放到s1中</p> 本帖最后由 作者 于 2007-8-6 11:10:01 编辑 <br /><br /> <p>(setq i 0 ss3 ss2))</p><p>(while (setq name(ssname ss1 i))</p><p>(if (not (ssmemb name ss2))</p><p>(ssadd name ss3))</p><p>(setq i (1+ i))</p><p>)</p> (setq SS1 (ssget))<br/> (print "OK1!")<br/> (setq SS2 (ssget))<br/> (command "_.SELECT" SS1 SS2 "")<br/> (setq SS3 (ssget "P"))<br/> <img alt="" src="http://www.mjtd.com/bbs/Skins/default/topicface/face15.gif"/>差距啊 今天学习的两个通用函数:
;;; ==================================================================
;;; 通用函数
;;; 两选择集的差集
(defun SSDIFF (SS1 SS2)
(command "_.select" SS1 "remove" SS2 "")
(ssget "P")
)
;;; 两选择集的并集
(defun SSUNION (SS1 SS2)
(command "_.select" SS1 SS2 "")
(ssget "P")
)
;;; ==================================================================
<p>举一反三,还差一个阿</p><p>求交集.hehe.路过</p><p>(defun SSins (SS1 SS2)<br/> (command "_.select" SS1 "r" SS2 "")<br/> (setq ss (ssget "P"))</p><p> (command "_.select" SS1 "r" SS "")</p><p> (ssget "P")<br/>)<br/></p> 本帖最后由 作者 于 2007-8-8 19:11:57 编辑 <br /><br /> <p>(defun ssinter (sssel1 sssel2 / sssel3)<br/> (command ".select" sssel1 "r" sssel2 "")<br/> (command ".select" sssel1 "r" "p" "")<br/> (setq sssel3 (ssget "p"))<br/> sssel3<br/>)</p> ;;;a+b和b+c,求a+c<br/>;;;方式 : (setq ss3 (ss-ac ss1 ss2))<br/>(defun ss-ac (sssel1 sssel2 / sssel3)<br/> (command ".select" sssel1 "R" sssel2 "")<br/> (command ".select" sssel2 "R" sssel1 " a" "p" "")<br/> (setq sssel3 (ssget "p"))<br/> sssel3<br/>)<br/>
页:
[1]
2