[script] acad layers > 3dsmax layers per color

Hi people,

A quick script that goes thrue all selected objects in the scene and puts it on a new layer.
that layer will have the same wirecolor.
So instead of more then 40 layers in max (that came from autocad) you get a couple new ones with the wirecolors kept.

Perhaps handy to some1.

NumberOfColors = #()
NewLayers = #()
for i in selection do (
    --build an array with the colors used in the scene appendUnique is a new function
    appendIfUnique NumberOfColors i.wirecolor
)
for i = 1 to NumberOfColors.count do (
    -- create Layers of the colors
    LayerName = “Color Layer :” + i as string
    NewLayers = LayerManager.newLayerFromName LayerName
    NewLayers.wireColor = NumberOfColors
*    -- all layers are created now, now only add the objects to the layer and we are done.*
)
for i in selection do (
        for t = 1 to NumberOfColors.count do (
            -- for each color check get layer and check
            LayerName = “Color Layer :” + t as string
            tmp = LayerManager.getLayerFromName LayerName
            if tmp.wireColor == i.wirecolor do (tmp.addNode i)
        )
)

print "And we are done… :slight_smile: "

Btw : it’s not fool proof hehe, no checks and such so… :slight_smile:

It seems very useful for me. I will try it.

Thank you.

Fun, thanks for sharing.

Heres an additional script thats useful to just get rid of the excessive amount of empty layers left over when cleaning up autocard layer schemes.


toolTip="Delete Unused Layers"
buttonText="Delete Unused Layers"

--start macro

--Delete all layers that have no objects in them and are not the current layer

LayDelete = #()
for i = 1 to (LayerManager.count-1) do 
(
	append LayDelete (LayerManager.getlayer i).name
)
print LayDelete
for i = 1 to LayDelete.count do
(
	LayerManager.deleteLayerByName LayDelete[i]
)