PDA

View Full Version : Can I change Red layers to White with LISP?



pmedina
2004-09-16, 12:55 PM
I don't know enough to do it. I want any layers whose color is 1 (red) to be changed to 7 (white). This is to accommodate a changeover to a company standard CTB.

Thank you for any help provided.

stig.madsen
2004-09-16, 01:17 PM
You could sort layers by color in the layer dialog, select all red ones and do the changes. Or define a layer filter, activate it and do the same.

Or, here's a simple quickie (with hardcoded values for colors):

(defun red2white (/ la)
(while (setq la (tblnext "LAYER" (not la)))
(cond ((= (cdr (assoc 62 la)) 1)
(setq la (entget (tblobjname "LAYER" (cdr (assoc 2 la)))))
(entmod (subst (cons 62 7)(assoc 62 la) la))))))

pmedina
2004-09-16, 03:53 PM
Got it. I got this a while back, but forgot about it.


;ORIGINAL FROM EMAIL:
; (defun C:100to200 (/ l ll)
; (while (setq l (tblnext "LAYER"(not l)))
; (cond ((= (cdr (assoc 62 l)) 100)
; (setq ll (entget (tblobjname "LAYER"(cdr (assoc 2 l)))))
; (entmod (subst (cons 62 200) (assoc 62 ll) ll)) ) ) ) )
;
;
;
(defun C:10to1 (/ l ll)
(setvar "cmdecho" 0)
(while (setq l (tblnext "LAYER"(not l)))
(cond ((= (cdr (assoc 62 l)) 10)
(setq ll (entget (tblobjname "LAYER"(cdr (assoc 2 l)))))
(entmod (subst (cons 62 1) (assoc 62 ll) ll)) ) ) )
(setvar "cmdecho" 1)
(ALERT "Layers with color 10 changed to color 1")
(PRINC "\n Layers with color 10 changed to color 1")
(princ)
)

stig.madsen
2004-09-17, 12:26 PM
Good thing no one claimed copyright to that method :)
Well, a few hundred people probably did already but ..