[Closed] Flatten layer hierarchy
I’m sorry for bombarding the forum with questions lately, but I was wondering if there’s some way to flatten the hierarchy of the Layers in 3dsMax? Whenever I create a new layer with another one selected, it adds it below the current one. I would like to create a script that just flattens the hierarchy of all of my layers if possible?
fn flattenLayer layer =
(
res = false
while (layer.getNumChildren() > 0) do
(
res = res or (LayerManager.deleteLayerHierarchy (layer.getChild 1).name forceDelete:on)
)
res
)
fn flattenLayerByName name =
(
layer = LayerManager.getLayerFromName name
if layer != undefined do flattenLayer layer
)
flatten all:
fn flattenAllLayers =
(
layers = for k=0 to LayerManager.count-1 where (layer = LayerManager.getLayer k).getParent() == undefined collect layer
for layer in layers do flattenLayer layer
)
(
for i = 1 to layerManager.count where (layer = (layerManager.getLayer i)) != undefined do layer.setParent undefined
)
merge nested layer nodes to parent and delete empty … that’s what I guess
I tought of flattening a hierarchy as if you would unparent any node from a hierarchy, so miauu’s solution did exactly what I wanted. I should have been able to find the setParent flag from the documentation though, but it seems I missed it
Thank you both.
Recent Topics
-
Need help with script to automate certain things
By siddhartha 7 days ago
-
By Dave 3 months ago
-
By MZ1 1 year ago
-
By brianstorm 1 year ago
-
By MZ1 1 year ago
-
Support class with multiple name (C#,SDK)
By MZ1 1 year ago
-
How to sort subarrays for Mat ID swapping
By brianstorm 1 year ago