Darken Layer Colors...

Sage Cowsert

Usenet Archive
Joined
Jul 25, 2003
Messages
44
Reaction score
0
Every once in a while I'd like to have a few layers stand out on my screen almost like an in place block & xref edit does but for non blocks.

Has anyone writen code to do this. Say turn all layers that are color Green to color 84?
 
Like this?
;; Routine to swap layer color. All layers of 'oldcol' will be 'newcol' ;; by Jeff Mishler, 7/29/03 ;; usage - (lay_color 2 84) this will change all layers with yellow(2) to 84 ;; Note: colors must be in integer form, no names allowed

(defun lay_color (oldcol newcol / lay)
(while (setq lay (tblnext "layer" (not lay)))
(setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay))))) (if (= oldcol (cdr (assoc 62 lay))) (progn (setq lay (subst (cons 62 newcol) (assoc 62 lay) lay)) (entmod lay) ) ) ) (princ)
)

Jeff
 
Thanks Jeff. I swear I tried that earlier but it didn't work. Works great now. Where's what I ended up with. Btw... this uses Bonus tools.

(defun c:darken (/ lay colorlist lay asslist newcol)
(load "lman")
(bns_sl "PreDarken")
(setq colorlist
(list '(1 14) '(2 54) '(3 94) '(4 134) '(5 166) '(6 216) '(7 253) '(8
251))
)
(while (setq lay (tblnext "layer" (not lay)))
(setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay))))) (if (setq asslist (assoc (cdr (assoc 62 lay)) colorlist)) ;oldcol (cdr (assoc 62 lay))) (progn (setq oldcol (car asslist) newcol (cadr asslist) ) (setq lay (subst (cons 62 newcol) (assoc 62 lay) lay)) (entmod lay) ) ) ) (princ)
)

(defun c:undarken
(bns_rl "Predarken")
(bns_dl "PreDarken")
)

Jeff Mishler said:
Like this?
;; Routine to swap layer color. All layers of 'oldcol' will be 'newcol' ;; by Jeff Mishler, 7/29/03 ;; usage - (lay_color 2 84) this will change all layers with yellow(2) to 84 ;; Note: colors must be in integer form, no names allowed

(defun lay_color (oldcol newcol / lay)
(while (setq lay (tblnext "layer" (not lay)))
(setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay))))) (if (= oldcol (cdr (assoc 62 lay))) (progn (setq lay (subst (cons 62 newcol) (assoc 62 lay) lay)) (entmod lay) ) ) ) (princ)
)

Jeff
 
Or, for the Bonus\Express Tools impaired:

;;Routine to swap layer colors.
;;by Jeff Mishler, 7/29/03

(defun lay_color (/ colorlist lay assoclist)
(setq colorlist
(list
'(1 14) '(2 54) '(3 94) '(4 134) '(5 166) '(6 216) '(7 253) '(8 251) ) ) (if lightflag (setq colorlist (mapcar 'reverse colorlist))) (while (setq lay (tblnext "layer" (not lay))) (setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay))))) (if (setq assoclist (assoc (cdr (assoc 62 lay)) colorlist)) (progn (setq lay (subst (cons 62 (cadr assoclist)) (assoc 62 lay) lay)) (entmod lay) ) ) ) (princ)
)

(defun c:darken
(lay_color)
(princ)
)

(defun c:lighten (/ lightflag)
(setq lightflag t)
(lay_color)
(princ)
)

Sage Cowsert said:
Thanks Jeff. I swear I tried that earlier but it didn't work. Works great now. Where's what I ended up with. Btw... this uses Bonus tools.

(defun c:darken (/ lay colorlist lay asslist newcol)
(load "lman")
(bns_sl "PreDarken")
(setq colorlist
(list '(1 14) '(2 54) '(3 94) '(4 134) '(5 166) '(6 216) '(7 253) '(8
251))
)
(while (setq lay (tblnext "layer" (not lay)))
(setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay))))) (if (setq asslist (assoc (cdr (assoc 62 lay)) colorlist)) ;oldcol (cdr (assoc 62 lay))) (progn (setq oldcol (car asslist) newcol (cadr asslist) ) (setq lay (subst (cons 62 newcol) (assoc 62 lay) lay)) (entmod lay) ) ) ) (princ)
)

(defun c:undarken
(bns_rl "Predarken")
(bns_dl "PreDarken")
)
 
Interesting. The only concern I have is that you may be merging one color with an existing one. When its lightened it'll change it.

Say for example. Color starts out as color 14.

Darken doesn't do anything with it. Lighten changes it to color 1.
 

Latest threads

Back
Top