关于ssget 获取多种图形实体的方法
用ssget获取圆和直线的代码如下(setq ss1 (ssget '((0 . "LINE"))))
(setq ss2 (ssget '((0 . "circle"))))但是要选择两次,无疑是个笨办法.所以我把它改成
(setq sss (ssget'((0 . "LINE,circle")))) 问题来了,我如何将其分离,就是把直线实体赋给选择集ss1,圆实体赋给选择集ss2 ?
我的解决办法如下
(defun c:test ()
(setq ss1 nil ss2 nil)
(if (setq ss1 (ssget '((0 . "LINE,circle"))))
(foreach itm (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))
(if (= (cdr (assoc 0 (entget itm))) "CIRCLE")
(progn
(or ss2 (setq ss2 (ssadd)))
(ssadd itm ss2)
(ssdel itm ss1)
)
)
)
)
)期待各路高手的讲解,希望在此跟帖,看到您的解决办法.最后请斑竹评一下谁的代码最实用最精简.谢谢大家!
.
(defun c:test ()
(setq ss1 nil ss2 nil)
(if (setq ss1 (ssget '((0 . "LINE,circle"))))
(progn
(setq ss2 (ssget "p" '((0 . "circle"))))
(command "select" ss1 "")
(setq ss1 (ssget "p" '((0 . "LINE"))))
)
)
) MARK~~~~~~ 谢谢楼主分享,代码很巧妙 刚好前一段写代码有碰到这个问题,跟大家分享一下吧,我是这种做法
(setq ss(ssget))
;墙
(setq ss-wall(ssget "p" (list(cons 0 "TCH_WALL"))))
(sssetfirst nil ss)
;窗
(setq ss-window(ssget "p" (list(cons 0 "TCH_OPENING")(cons71 1))))
(sssetfirst nil ss)
;柱
(setq ss-column(ssget "p" (list(cons 0 "TCH_COLUMN")))) 谢谢楼主,学习学习 (defun c:tt ()
(if (setq ss (ssget '((0 . "LINE,circle"))))
(progn (setq ss1 (ssadd)
ss2 (ssadd)
i -1
)
(while (setq s1 (ssname ss (setq i (1+ i))))
(if (= (cdr (assoc 0 (entget s1))) "LINE")
(ssadd s1 ss1)
(ssadd s1 ss2)
)
)
)
)
)
;; 伪源码方式
(defun c:tt ()
(if (setq ss (ssget '((0 . "LINE,circle"))))
(setq ss1 (ssget "p" '((0 . "LINE")))
ss2 (ssdiff ss ss1)
)
)
)
(defun c:test (/ SS _OC)
(if (setq ss (ssget '((0 . "LINE,CIRCLE"))))
(progn
(setq ss1 (ssget "p" '((0 . "LINE"))))
(setq _oc (getvar 'CMDECHO))
(setvar 'CMDECHO 0)
(vl-cmdf "_Select"ss "")
(setvar 'CMDECHO _OC)
(setq ss2 (ssget "p" '((0 . "CIRCLE"))))
)
)
(princ)
) 学习了...又学到一个好方法..谢谢