cedwards Posted August 31, 2010 Posted August 31, 2010 Greeting everyone, Below is a layer color changing lisp that I use alot. I was wondering if someone could help me modify it to ignore locked layers. Any help would be greatly appreciated! Thanks (defun c:cdwg () (command "chprop" "all" "" "c" "bylayer" "") (command "-layer" "c" 8 "*" "c" 8 "0" "c" 8 "defpoints" "") (progn (setq tbl(tblnext "LAYER" T)) (while (/= tbl nil) (setq layName(cdr(assoc 2 tbl))) (if(wcmatch layName "*wall*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*WALL*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*Wall*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*door*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*DOOR*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*Door*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*glaz*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*GLAZ*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*Glaz*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*glass*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*GLASS*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*Glass*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*window*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*WINDOW*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "*Window*") (command "-layer" "C" 4 layName "") ) (if(wcmatch layName "0") (command "-layer" "C" 7 layName "") ) ) (command "layer" "s" 0 "") (command "purge" "a" "*" "n") (command "regen") (command "zoom" "e") Quote
BlackBox Posted August 31, 2010 Posted August 31, 2010 (edited) My two cents... (defun c:CDWG (/ oldCmdecho layerTable layerName layerColor) (vl-load-com) (cond (*activeDoc*) ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object))))) (vla-startundomark *activeDoc*) (vla-purgeall *activeDoc*) (if (/= 0 (setq oldCmdecho (getvar 'cmdecho))) (setvar 'cmdecho 0)) (vl-cmdf "._chprop" "all" "" "color" "bylayer" "") (if (setq layerTable (vla-get-layers *activeDoc*)) (vlax-for x layerTable (if (and (setq layerName (strcase (vla-get-name x))) (= :vlax-false (vla-get-lock x))) (progn (cond ((vl-position layerName (list "*DOOR*" "*GLASS*" "*GLAZ*" "*WALL*" "*WINDOW*")) (setq layerColor 4)) ((= "0" layerName) (setq layerColor 7)) (T (setq layerColor )) (vla-put-color x layerColor))))) (vla-zoomextents (vla-get-application *activeDoc*)) (setvar 'cmdecho oldCmdecho) (terpri) (prompt "\nLayer Settings Complete. ") (terpri) (vla-endundomark *activeDoc*) (princ)) ;_end defun Edited August 31, 2010 by BlackBox Quote
cedwards Posted August 31, 2010 Author Posted August 31, 2010 thanks Render.....it semi works. It changes everything to color 8 except for the locked layers, but it doesn't changes the list items to color 4. any suggestions? Quote
BlackBox Posted August 31, 2010 Posted August 31, 2010 thanks Render.....it semi works. It changes everything to color 8 except for the locked layers, but it doesn't changes the list items to color 4. any suggestions? My mistake , let's try this revision: (defun c:CDWG (/ oldCmdecho layerTable layerName layerColor) (vl-load-com) (cond (*activeDoc*) ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object))))) (vla-startundomark *activeDoc*) (vla-purgeall *activeDoc*) (if (/= 0 (setq oldCmdecho (getvar 'cmdecho))) (setvar 'cmdecho 0)) (vl-cmdf "._chprop" "all" "" "color" "bylayer" "") (if (setq layerTable (vla-get-layers *activeDoc*)) (vlax-for x layerTable (if (and (setq layerName (strcase (vla-get-name x))) (= :vlax-false (vla-get-lock x))) (progn (cond ([color=blue]([color=red]wcmatch[/color] layerName "*DOOR*,*GLASS*,*GLAZ*,*WALL*,*WINDOW*")[/color] (setq layerColor 4)) ((= "0" layerName) (setq layerColor 7)) (T (setq layerColor )) (vla-put-color x layerColor))))) (vla-zoomextents (vla-get-application *activeDoc*)) (setvar 'cmdecho oldCmdecho) (terpri) (prompt "\nLayer Settings Complete. ") (terpri) (vla-endundomark *activeDoc*) (princ)) ;_end defun Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.