Batch for layers

Batch for layers

alaafarhat
Enthusiast Enthusiast
953 Views
2 Replies
Message 1 of 3

Batch for layers

alaafarhat
Enthusiast
Enthusiast

Greetings,

 

I would like to ask if someone have a batch file , that would let me change all the layers to one color with exception of one of more layers that i can specify to the batch file ,

and in case its possible also , since i need to remove layout from this DWG ,

Please note that we have hundreds of DWGS , that's why i am looking for a batch file

 

Thank you for the help

 

0 Likes
954 Views
2 Replies
Replies (2)
Message 2 of 3

Moshe-A
Mentor
Mentor

check this:

 

for Color prompt enter a numeric color value

 

for Exclude Layers enter "layer1,layer2,layer2"

pressing just enter or '*' will set the same color to all layers including xref layers

 

 

(defun c:SetOneClr (/ clr ExcludeLayers tbl LayerName)
 (if (and
       (setq clr (getint "\nColor: "))
       (setq ExcludeLayers (getstring "\nExclude Layer(s) or ENTER to set same color to all: "))
     )
  (progn
   (while (setq tbl (tblnext "layer" (not tbl)))
    (setq LayerName (cdr (assoc '2 tbl)))

    (if (or (eq ExcludeLayers "") (eq Excludelayers "*")) 
     (command "layer" "color" clr LayerName "")
     (if (not (wcmatch (strcase LayerName) (strcase ExcludeLayers)))
      (command "layer" "color" clr LayerName "")
     )
    ); if
   ); while
  ); progn
 ); if

 (princ)
)

on a second thought i do not see why do you need such a function cause layer property manager palette is so modern will let you select all layer with a mouse few clicks and exclude layers with few clicks - no?!

 

Moshe

 

 

Message 3 of 3

alaafarhat
Enthusiast
Enthusiast
Thank you Moshe for providing me with this code, knowing that setbylayer from inside an Autocad Dwg will help too,
what i am looking for first is to change all layers that are needed to be changed from outside the dwgs since there is a lot of dwgs with adding exception for two or three layers to be locked or not visible for this batch file
Thank you for your help
0 Likes