Change all layers to Orange or Combine all layers to one layer

Change all layers to Orange or Combine all layers to one layer

sjelen
Contributor Contributor
1,157 Views
24 Replies
Message 1 of 25

Change all layers to Orange or Combine all layers to one layer

sjelen
Contributor
Contributor

Good morning all -

Looking for a little help here. I've gotten about 90% of the way there. I am having a hang up with changing all layers to one color, if this is not attainable then possibly I can combine all layers into one layer and change that one layer to the color I want. I was using the Layer Translator previously to combine all layers and then would choose the color I wanted that layer to be but again if I could just type in my command to perform all my functions that would be ideal. 

 

Thank you all for your help, here is my code so far. 

 

(defun c:TCD-PLB ()
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq layers (vla-get-Layers doc))
(setq newLayerName "XREF")

; Create a new layer
(setq newLayer (vla-Add layers newLayerName))
(vla-put-Color newLayer acOrange)
(vla-put-PlotStyleName newLayer "Normal")

; Delete dimensions on the "A-ANNO-DIMS" layer
(vlax-for obj (vla-get-ModelSpace doc)
(if (= (vla-get-Layer obj) "A-ANNO-DIMS")
(vla-erase obj)
)
)

; Delete dimensions on the "S-GRID-IDEN" layer
(vlax-for obj (vla-get-ModelSpace doc)
(if (= (vla-get-Layer obj) "S-GRID-IDEN")
(vla-erase obj)
)
)

; Delete gridlines on the "S-GRID-1" layer
(vlax-for obj (vla-get-ModelSpace doc)
(if (= (vla-get-Layer obj) "S-GRID-1")
(vla-erase obj)
)
)

; Delete gridlines on the "S-GRID-2" layer
(vlax-for obj (vla-get-ModelSpace doc)
(if (= (vla-get-Layer obj) "S-GRID-2")
(vla-erase obj)
)
)

(princ "\nTCD PLB executed successfully.")
)

(princ)

0 Likes
1,158 Views
24 Replies
Replies (24)
Message 21 of 25

sjelen
Contributor
Contributor

sjelen_0-1701972012353.png

 

These are the layers and for this particular document it'll have this ID-109 drawing in there but will change for different floors. So just as I call out other layers like GRIDS to delete I would like to call out an ID layer that they've added. But those layers wont stay constant like the GRIDS layer. So if I could call out for an ID layer that picked up on the ID part and not on the entire name that would be ideal. 

 

0 Likes
Message 22 of 25

sjelen
Contributor
Contributor

Interesting, ok so calling out for a property of a layer like the color and if it's set as ByLayer or Color etc, we would use a different command to change all the layer properties to ByLayer so that when I make the command to change all layers to a specific color they'll all change? The issue I'm having on a particular file is 90% change to Orange but the certain layers where their properties are different, those layers don't change color. 

0 Likes
Message 23 of 25

Kent1Cooper
Consultant
Consultant

@sjelen wrote:

Interesting, ok so calling out for a property of a layer like the color and if it's set as ByLayer or Color etc, we would use a different command to change all the layer properties to ByLayer so that when I make the command to change all layers to a specific color they'll all change? The issue I'm having on a particular file is 90% change to Orange but the certain layers where their properties are different, those layers don't change color. 


Again, you cannot set or change the color of a Layer to "ByLayer."  [Try to do so manually.]  Nor can you change any other properties of a Layer to "ByLayer" [linetype, etc.].  Only objects can have that as their color [or linetype, etc.].  If things on some Layers are not changing to the color of the Layer they are on, when you have changed the color of all Layers to orange, it is the color property of the objects on those Layers that is different, not a property of the Layers.  You need to change the color of the objects to ByLayer.

 

That may still not change the color of absolutely everything.  You may need to get into Block definitions and change the color of all the objects in them to ByLayer.  And you could have partial or complete color overrides in Mtext and MultiLeader internal formatting, that you would need to strip out.  And you could have parts of things like Dimensions that have a different color assigned, so you may need to get into Dimension Style definitions and correct colors there.

Kent Cooper, AIA
0 Likes
Message 24 of 25

sjelen
Contributor
Contributor

Alright thanks, trying to eliminate any manual processing aside from typing in my command. Did you see my response to the ID question?

0 Likes
Message 25 of 25

Kent1Cooper
Consultant
Consultant

@sjelen wrote:

.... So if I could call out for an ID layer that picked up on the ID part and not on the entire name that would be ideal. 


That should be doable in the same way as for those other Layers with complete known names, but using (wcmatch) instead of (=) to check the Layer name.  Untested:

 

; Delete everything on "ID-anything" layer(s)
(vlax-for obj (vla-get-ModelSpace doc)
  (if (wcmatch (strcase (vla-get-Layer obj)) "ID-*")
    (vla-erase obj)
  )
)

 

[You could eliminate the (strcase) wrapper if they will reliably always start with capitalized ID.  As written, it would also take care of things if a Layer name starts with Id- or id- or iD-.]

Kent Cooper, AIA
0 Likes