I have used this routine a lot. I sometimes get drawings that have attributes that have had their color changed to something other than “BYLAYER.” This routine will change all attributes colors to be BYLAYER.
- After loading, simply type in CHGATTCOL <enter> to start and it finishes from there.
Note: if you need to change both the geometry and attribute color to BYLAYER, use the SETBYLAYER command that is already in AutoCAD.
;change all attribute colors to bylayer (defun C:ChgAttCol (/ name ss sslen cnt blck ent entinfo) ;(setq name (strcase (getvar "loginname"))) (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 256) (assoc 62 entinfo) entinfo)) ) (entupd ent) (setq ent (entnext ent)) (setq entinfo (entget ent)) ) (setq cnt (1+ cnt)) ) (princ) )