像这样的
- (defun C:test ( / del ct *error* SS LyrStates i enx col lyr nlyr tmp )
- (setq del "_") ; Delimeter
- (setq ct
- '(
- (1 . "Red") (2 . "Yellow") (3 . "Green") (4 . "Cyan")
- (5 . "Blue") (6 . "Magenta") (7 . "Whilte")
- )
- )
-
- (defun *error* ( m )
- (and ThawUnlockLyrs LyrStates (ThawUnlockLyrs LyrStates))
- (and m (princ m)) (princ)
- ); defun *error*
-
- (if (setq SS (ssget "X"))
- (progn
- (and ThawUnlockLyrs (setq LyrStates (ThawUnlockLyrs nil)))
- (repeat (setq i (sslength SS))
- (and
- (setq col (assoc 62 (setq enx (entget (ssname SS (setq i (1- i)))))))
- (vl-every '(lambda (x) (not (assoc x enx))) '(420 430))
- (setq lyr (assoc 8 enx))
- (setq nlyr (strcat (cdr lyr) del (cond ( (cdr (assoc (setq tmp (cdr col)) ct)) ) ( (itoa tmp) ) )))
- (progn
- (entmod (subst '(62 . 256) col (subst (cons 8 nlyr) lyr enx)))
- (entmod (append (entget (tblobjname "LAYER" nlyr)) (list col)))
- )
- )
- )
- )
- )
- (*error* nil) (princ)
- )
- (vl-load-com) (princ)
- ; (setq LyrStates (ThawUnlockLyrs nil))
- ; (and LyrStates (ThawUnlockLyrs LyrStates))
- (defun ThawUnlockLyrs ( aL / d L st enx )
- (cond
- (aL
- (foreach x aL
- (if (setq enx (entget (tblobjname "LAYER" (car x))))
- (entmod (subst (cons 70 (cadr x)) (assoc 70 enx) enx))
- ); if
- ); foreach
- )
- (T
- (while (setq d (tblnext "LAYER" (not d)))
- (setq L (cons (apply 'append (mapcar '(lambda (x) (if (member (car x) '(2 70)) (list (cdr x)))) d)) L))
- (setq st
- (
- (lambda (x)
- (if (= 1 (logand 1 x)) (setq x (1+ x))) ; Frozen
- (if (= 4 (logand 4 x)) (setq x (+ 4 x))) ; Locked
- x
- )
- (cadar L)
- )
- ); setq st
- (setq enx (entget (tblobjname "LAYER" (caar L))))
- (entmod (subst (cons 70 st) (assoc 70 enx) enx))
- ); while
- L
- ); T
- ); cond
- ); defun ThawUnlockLyrs
|