;****************************************************单开图层
(DEFUN C:SS (/ ES EN EL A)
(princ "请选择对象,未被选中的对象所在的层将被关闭")
(setq ES (ssget)
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:CL (/ i lyset sa len lyn)
(prompt "请选择对象设置当前图层")
(setq sa (ssget)
len (sslength sa)
i 0
)
(while (< i len)
(setq lyn (cdr (assoc 8 (entget (ssname sa i))))
i (+ i 1)
)
(if (null (member lyn lyset))
(setq lyset (cons lyn lyset))
)
)
(command "layer" (setq lyn (car lyset)
lyset (cdr lyset)
)
(command "layer" "on" lyn "")
)
(command "layer" "s" lyn "")
)