关于sssetfirst实现“夹点亮显”的问题
本帖最后由 言社长 于 2015-12-20 19:38 编辑以下是@lucas_3333写的一段代码,功能是“隐藏相同颜色的图元,包括随层图层颜色”。
我想用sssetfirst实现“夹点亮显相同颜色的图元,包括随层图层颜色”,应该怎么改呢?
本人初接触LISP,还望各位包涵,请赐教!(defun c:test (/ ss ssn n cor m ss1 pd ssm)
(princ "\n请选择需要隐藏的颜色:")
(setq ss (nth 0 (entsel)))
(command "undo" "be")
(setvar "cmdecho" 0)
(setq cor (assoc 62 (entget ss))) ;颜色如果随层,按图层颜色
(if (= cor nil)
(progn (setq tc (cdr (assoc 8 (entget ss))))
(setq tc (tblsearch "layer" tc))
(setq cor (assoc 62 tc))
)
)
;;;找出不是随层符合颜色的对象
(setq ss (ssget "x" (list cor)))
(if (/= ss nil)
(progn (setq n 0)
(while (< n (sslength ss))
(setq ssn (ssname ss n))
(setq ssn (entget ssn))
(setq ssn (append ssn '((60 . 1))))
(entmod ssn)
(setq n (1+ n))
)
)
)
;;;找出随层符合颜色的对象
(setq tc (tblnext "layer" "0"))
(while (/= tc nil)
(if (equal cor (assoc 62 tc))
(progn (setq ss1 (ssget "x" (list (cons 8 (cdr (assoc 2 tc))))))
(if (/= ss1 nil)
(progn (setq m 0)
(while (< m (sslength ss1))
(setq ssm (entget (ssname ss1 m)))
(setq pd (assoc 62 ssm))
(if (= pd nil)
(progn (setq ssm (append ssm '((60 . 1)))) ;
(setq ssm (cons '(60 . 1) ssm))
(entmod ssm)
)
)
(setq m (1+ m))
)
)
)
)
)
(setq tc (tblnext "layer"))
)
(command "undo" "e")
(princ)
) (defunc:tt()
(setq lay (cdr(assoc 8(entget(car(entsel"点取图层"))))))
(setq ss_x (ssget"x" (list (cons 8 lay))))
(sssetfirstnil ss_x)
) 434939575 发表于 2015-12-20 19:33 static/image/common/back.gif
你好,可能我没表达清楚,我的原代码是隐藏相同颜色的图元,我想改成夹显相同颜色的图元。我搞不懂sssetfirst后面要跟哪个量才是正确。
你的代码是夹显相同图层,可能不是我想要的 言社长 发表于 2015-12-20 19:42 static/image/common/back.gif
你好,可能我没表达清楚,我的原代码是隐藏相同颜色的图元,我想改成夹显相同颜色的图元。我搞不懂sssetf ...
后面跟选择集 (defun c:ts (/ co en en1 ent n ss ss1 tc)
(if (setq ent (entsel "\n请选择需要隐藏的颜色:"))
(progn
(setq en (car ent))
;;颜色如果随层,按图层颜色
(if (not (setq co (assoc 62 (entget en))))
(progn
(setq tc (cdr (assoc 8 (entget en))))
(setq tc (tblsearch "layer" tc))
(setq co (assoc 62 tc))
)
)
;;找出不是随层符合颜色的对象
(if (null (setq ss (ssget "x" (list co))))
(setq ss (ssadd))
)
;;找出随层符合颜色的对象
(setq tc (tblnext "layer" "0"))
(while tc
(if (equal co (assoc 62 tc))
(progn
(if (setq ss1 (ssget "x" (list (cons 8 (cdr (assoc 2 tc))))))
(repeat (setq n (sslength ss1))
(setq en1 (ssname ss1 (setq n (1- n))))
(if (not (assoc 62 (entget en1)))
(ssadd en1 ss)
)
)
)
)
)
(setq tc (tblnext "layer"))
)
(sssetfirst nil ss)
)
)
(princ)
)我改改试试 本帖最后由 llsheng_73 于 2015-12-25 23:24 编辑
(defun c:ts(/ e co la);;亮显全图中与所拾取图元颜色一样的图元(所有正常显示图层)
(While(SetQ e(TblNext "layer"(not la)))(SetQ la(Cons(mapcar'(lambda(x)(assoc x e))'(2 62))la)))
(if(setq e(car(entsel"拾取要亮显的颜色")))
(sssetfirst'nil(setq e(entget e)
co(assoc 62 e)
co(if co co(assoc 62(tblsearch"layer"(cdr(assoc 8 e)))))
e(ssget"X"(list'(-4 . "<or")co
'(-4 . "<and")'(62 . 256)
(cons 8(apply'strcat(mapcar'(lambda(x)(if(member co x)(strcat","(cdar x))""))la)))
'(-4 . "and>")'(-4 . "or>")))))))
页:
[1]