- ;;; 关闭对像所在层
- (defun lf (ss / c en lay)
- (setq c 0)
- (while (< c (sslength ss))
- (setq en (ssname ss c))
- (setq lay (cdr (assoc 8 (entget en))))
- (if (not (member lay laylst))
- (setq laylst (cons lay laylst))
- )
- (if (= lay (getvar "clayer"))
- (command "-layer" "off" lay "y" "")
- (command "-layer" "off" lay "")
- )
- (setq c (+ 1 c))
- )
- (princ)
- )
- ;;; 只显示被选对像所在层
- (DEFUN lg (Es / ES EN EL A)
- (setq A 0 EN "" EL nil FL nil)
- (while (/= EN nil)
- (setq EN (ssname ES A) EL (cons EN EL) A (1+ A)))
- (setq EL (cdr EL) FL (cdr (assoc ' 8 (entget (car EL)))) EL (cdr EL))
- (repeat (- A 2)
- (setq EN (cdr (assoc ' 8 (entget (car EL))))
- FL (strcat EN "," FL) EL (cdr EL)) )
- (command "LAYER" "off" "*" "y" "on" (eval FL) "")
- (princ)
- )
- (defun C:Lyr2 ()
- (princ "\n选择要关闭的图层(或空格,再选择不关闭的图层 )")
- (setq ss (ssget))
- (cond
- ;; 空格选择不关闭的图层
- ((Null ss) (lg (ssget)))
-
- (T (lf ss))
- )
- )
|