- (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)
- )
我改改试试 |