Can you please post a drawing that it does not change. It could be helpful.
Thanks,
Brian
Registered forum members do not see this ad.
I have some code that I came across that needs a little updating. It was created by a gentlemen named Paul Mofers back in 2001. The only problem is it's now 2008 and I cannot find him or figure this thing out. Honestly I'm a LISP newbie and the more I search the more dead ends I hit. This code actually works great, but I noticed it's not changing the layers for HATCHES, SOLIDS, and MTEXT, and possibly others. Bascially I want it to change everything if possible. Thanks in advance!
Code:;;; Paul Mofers ;;; 27-11-2001 ;;; (defun c:clkc () (ChangeLayerKeepColor) (princ) ) (defun ChangeLayerKeepColor ( / SelectionSet LayerName counter EntData EntLayer EntColor Color) (prompt "\nSelect the entitie(s) you want to change the layer of... ") (setq SelectionSet (ssget)) (if (not SelectionSet) (prompt "\n There was nothing selected! ") (progn (setq LayerName (getstring "\nLayer name (Enter to exit): ")) (if (= LayerName "") (prompt "\nProgram ended... ") (if (tblsearch "LAYER" LayerName) (progn (setq counter 0) (repeat (sslength SelectionSet) (setq EntData (entget (ssname SelectionSet counter)) EntLayer (cdr (assoc 8 EntData)) EntColor (cdr (assoc 62 EntData)) ) (if (= EntColor nil) (setq EntColor (cdr (assoc 62 (tblsearch "LAYER" EntLayer))) Color T ) (setq Color nil) ) (setq EntData (subst (cons 8 LayerName)(assoc 8 EntData) EntData)) (if Color (setq Entdata (cons (cons 62 EntColor) Entdata)) (setq EntData (subst (cons 62 EntColor) (assoc 62 EntData) EntData)) ) (entmod EntData) (setq counter (1+ counter)) ) ) (prompt (strcat "\nLayername " LayerName " does not exist ! ")) ) ) ) ) )
Can you please post a drawing that it does not change. It could be helpful.
Thanks,
Brian
Registered forum members do not see this ad.
Maybe this program is conformable to your wishes:
Code:;;;CHANGE LAYER, KEEP COLORS PROGRAM ;;;Written by ssg - October 16th, 2007 ;;;------------------------------------------------------------------------ (defun GetLay(/ Lay Laylist) ;;;Get all layers in drawing. Return string (setq Lay (tblnext "LAYER" T) Laylist "") (While Lay (setq Laylist (strcat Laylist (cdr (assoc 2 Lay)) "/") Lay (tblnext "LAYER"))) Laylist ) ;;;------------------------------------------------------------------------ (defun getc(e / color tbl) ;;;Get color of entity e (if (not (setq color (cdr (assoc 62 (entget e))))) (setq tbl (tblsearch "layer" (cdr (assoc 8 (entget e)))) color (cdr (assoc 62 tbl)) ) ) color ) ;;;------------------------------------------------------------------------ (defun claykc(e lay / color) ;;;Change e to lay, keep color (setq color (getc e)) (command "change" e "" "p" "la" lay "c" color "") ) ;;;======================================= (defun C:CLK( / ss mylay e) ;;;Change layer, keep color. All objects selected by user (setq ss (ssget)) (if (not ss) (prompt "\nThere was nothing selected!") (progn (setq mylay (getstring (strcat "\nLayer name " (getlay) " <Enter to exit>:"))) (if (= mylay "") (exit)) (if (tblsearch "LAYER" mylay) (while (setq e (ssname ss 0)) (claykc e mylay) (ssdel e ss)) (prompt (strcat "\nLayername " mylay " does not exist!")) ) ) ) (princ) ) ;;;=======================================
Bookmarks