Been searching around finally found something and I need this to work, it is what I am currently looking for, Our new office standards went from 'Green' to '104' and have different layers such as 'tblock' and '0' or 'text' all with this color 'green' that I need batch changed to 104.
Basically doesnt matter what the layer is called, if the color is GREEN it needs to be 104 now which is more on the hunter green instead of a lime green.
Anyways, I am stumped how to get this routine pieced together to perform properly.
Any help?!?!
change the command name as you desire (after the c: )
;; by Juerg Menzi ;; http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Lisp-Routine-To-Change-Layer-Color/m-... (defun VxChgLayCol (Old New / AcdDoc) (vl-load-com) (setq AcdDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-for Obj (vla-get-Layers AcdDoc) (if (= (vla-get-Color Obj) Old) (vla-put-Color Obj New) ) (vlax-release-object Obj) ) (vlax-release-object AcdDoc) (princ) ) (defun c:chcolor104 () (VxChgLayCol 3 104));; change the command name
EDIT: If you're not used to using lisp files, this tutorial from Lee Mac may be useful...
HTH
Henrique
Hey my apologies, I misspoke when I requested the routine. The routine works perfectly, it changes the layers in the layer manager from green to 104 HOWEVER I meant I also needed to change the objects and text and stuff within the drawing that have the color set to GREEN changed to 104. That is what I really really need! The text and objects on layer green to be converted to 104!
My apologies for the confusion!!! Thanks look forward to your reply! GOD BLESS
Someone was able to squeeze me in their busy day and write something for me Here it is, You may Tweak to your liking I would assume, as long as you keep Tharwat AL Shoufi as PROPS HOLDER! God bless...
(defun c:104C (/ doc *error* ColorTo104 lst s) ;; Author : Tharwat AL Shoufi ;; ;; www.CadTutor.com 11.Oct.2013 ;; (or doc (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ) (defun *error* (u) (if lst (foreach it lst (vla-put-lock (vla-item (vla-get-layers doc) it) :vlax-true) ) ) (princ "\n *Cancel*") ) (defun ColorTo104 (ent) (if (eq 3 (vla-get-color ent)) (vla-put-color ent 104) ) ) (vlax-for l (vla-get-layers doc) (ColorTo104 l) (if (eq :vlax-true (vla-get-lock l)) (progn (vla-put-lock l :vlax-false) (setq lst (cons (vla-get-name l) lst)) ) ) ) (vla-startUndomark doc) (vlax-for b (vla-get-blocks doc) (if (and (eq :vlax-false (vla-get-IsXref b)) (eq :vlax-false (vla-get-IsLayout b)) ) (vlax-for x b (ColorTo104 x) ) ) ) (if (ssget "_X" '( (-4 . "<OR") (-4 . "<AND") (62 . 3) (-4 . "AND>") (-4 . "<AND") (0 . "INSERT") (66 . 1) (-4 . "AND>") (-4 . "OR>") ) ) (progn (vlax-for e (setq s (vla-get-ActiveSelectionSet doc)) (if (and (eq (vla-get-objectname e) "AcDbBlockReference") (eq :vlax-true (vla-get-hasattributes e)) ) (foreach att (vlax-invoke e 'GetAttributes) (ColorTo104 att) ) (ColorTo104 e) ) ) (vla-delete s) ) ) (if lst (foreach u lst (vla-put-lock (vla-item (vla-get-layers doc) u) :vlax-true) ) ) (vla-regen doc AcActiveViewport) (vla-EndUndoMark doc) (princ) ) (vl-load-com)