PDA

View Full Version : Global Color Change


f.tagle
2006-07-20, 04:01 AM
I need a LISP Routine that would change all the entities in a drawing (including nested blocks, attributes) to color bylayer without exploding/bursting any objects and without any dialog
box popping out.

Your help will be very much appreciated. Thanks

rkmcswain
2006-07-20, 02:53 PM
Looks like you got a bite...

http://discussion.autodesk.com/thread.jspa?threadID=486030

tedg
2006-07-25, 08:49 PM
I need a LISP Routine that would change all the entities in a drawing (including nested blocks, attributes) to color bylayer without exploding/bursting any objects and without any dialog
box popping out.

Your help will be very much appreciated. Thanks
You can try this, it changes everything's color to "ByLayer".
The only problem is that it redefines the blocks putting everything on layer zero.
So what ever layer the block was inserted on is what color it is.
You can test it on copy of a drawing first to make sure it does what you want.


;Redefines selected blocks so entities are on layer '0' (zero)
;Changes all entities' color to ByLayer paperspace & modelspace

(defun C:FXC (/ ss cnt idx blkname donelist Grp Update)
(defun Grp (gc el) (cdr (assoc gc el)))
(defun Update (bname / ename elist)
(setq ename (tblobjname "BLOCK" bname))
(if
(and ename (zerop (logand 52 (Grp 70 (entget ename '("*"))))))
(progn
(while ename
(setq elist (entget ename '("*"))
elist (subst '(8 . "0") (assoc 8 elist) elist)
elist (if (assoc 62 elist)
(subst '(62 . 0) (assoc 62 elist) elist)
(append elist '((62 . 0)))))
(entmake elist)
(setq ename (entnext ename)))
(if (/= "ENDBLK" (Grp 0 elist))
(entmake '((0 . "ENDBLK") (8 . "0") (62 . 0))))
'T))
)
(if (> (logand (Grp 70 (tblsearch "layer" "0")) 1) 0)
(princ "\nLayer 0 must be thawed before running FIXBLOCK!\n")
(progn
(if
(progn
(princ "\nPress <Enter> to fix all defined blocks\n")
(setq cnt 0
ss (ssget '((0 . "INSERT")))))
(progn
(setq idx (sslength ss))
(while (>= (setq idx (1- idx)) 0)
(if (not (member (setq blkname (Grp 2 (entget (ssname ss idx)))) donelist))
(progn
(if (Update blkname) (setq cnt (1+ cnt)))
(setq donelist (cons blkname donelist))))))
(while (setq blkname (Grp 2 (tblnext "BLOCK" (not blkname))))
(if (Update blkname) (setq cnt (1+ cnt)))))
(princ (strcat "\n" (itoa cnt) " block" (if (= cnt 1) "" "s") " redefined\n"))))
(command "tilemode" "1" "_chprop" "all" "" "color" "bylayer" "")
(command "tilemode" "0" "_chprop" "all" "" "color" "bylayer" "")
(command "zoom" "e" "zoom" ".9x" )
(command "purge" "a" "" "n") (PRINC)
)


Have Fun.

Ted

tyeelaw13
2006-08-08, 06:27 PM
I would think using the QSELECT command or even the change properties (CH) would be easier. You can just highlight everything, type in CH, and then for color it will probably say "VARIES", and just change that to bylayer.

rkmcswain
2006-08-08, 06:47 PM
I would think using the QSELECT command or even the change properties (CH) would be easier. You can just highlight everything, type in CH, and then for color it will probably say "VARIES", and just change that to bylayer.

That won't change nested entities or attributes.