Changing attributes color to a given number

A Diaz

Usenet Archive
Joined
Jan 8, 2004
Messages
24
Reaction score
0
Hello,

I am trying to change the attribute color to a given number. I have several drawings with a lot of blocks with attributes using color ByLayer. I want to globally change the color of my attributes to a different color. I did modified a code I found in this newgroup 2 years ago, but this is not working.
Here is the code:

(defun C:ChgAttColorToOther (/ name ss sslen cnt blck ent entinfo) (setq name (strcase (getvar "loginname"))) (initget 7) (setq AttribColor (getint "\n\nEnter New Attribute Color <11>: ")) (terpri) (cond ((not AttribColor) (setq AttribColor 11))) (setq ss (ssget "x" '((0 . "INSERT")))) (setq cnt 0) (setq sslen (sslength ss)) (while (< cnt sslen) (setq blck (ssname ss cnt)) (setq ent (entnext blck)) (setq entinfo (entget ent)) (while (and ent (= (cdr (assoc 0 entinfo)) "ATTRIB")) (if (assoc 62 entinfo) (entmod (subst (cons 62 AttribColor) (assoc 62 entinfo) entinfo)) ) (entupd ent) (setq ent (entnext ent)) (setq entinfo (entget ent)) ) (setq cnt (1+ cnt)) ) (princ)
)

What's wrong?
TIA
 
I found that the lisp works fine for block where the attribute is not color ByLayer. Any idea?
 
A Diaz said:
I found that the lisp works fine for block where the attribute is not color ByLayer. Any idea?

If I remember correctly ...

Code 62 does not exist when the color if BYLAYER. If that is so then you will need to add an else expression as shown in the code below.

(if (assoc 62 entinfo)
(entmod (subst (cons 62 AttribColor) (assoc 62 entinfo) entinfo)) ;else ... (append entinfo (cons 62 AttribColor))
)

Andy
 
Thank you Andy.
The code will be like this:

(if (assoc 62 entinfo)
(entmod (subst (cons 62 AttribColor) (assoc 62 entinfo) entinfo)) (setq entinfo (entmod (append entinfo (list (cons 62 AttribColor)))))
)
 

Latest threads

Back
Top