# Moving all sub layers up to become a top level parent? possible?

I would love a function where once i exploded all my blocks, where multiple block sub layers are named identically in different block parent layers (they’re no long blocks now, I’m just referring to them as block layers for ease of explanation). If i could move and merge all sub layers including any other level of sub layers (all bottom level sublayers will have object in).

For example, From this :

• Exploded block 1

• Finish 1
• 2mm Steel
• 3mm Steel
• Finish 2
• 2mm steel
• 3mm steel
• 18mm MDF
• Exploded Block 2

• Finish 1
• 2mm Steel
• Finish 2
• 18mm MDF
• Finish 3
• 3mm Acrylic

To This:

• Finish 1
• 2mm Steel
• 3mm Steel
• Finish 2
• 2mm Steel
• 3mm Steel
• 18mm MDF
• Finish 3
• 3mm Acrylic

If anyone knows a way of doing this with out going through potentially 100s of layers and re assigning all objects to layers and moving layers from parents etc I’d love to hear it!

Also what do you think of our layering system?

Currently using rhino 5 and rhino 6 (for make 2d)

Hello - in short you’d like to consolidate all layers at the same nesting level that have the same name, is that correct?

-Pascal

Hi Pascal, thanks for getting back to me.

yes that’s correct but also consolidate all the objects that were on those layers to one layer.

I’m intending to then feed these objects into grasshopper where I’ve made a definition that will extract the volume for these layers.

What do you think?

Thanks, Carlo

Hi Carlo- it should be possible, in a script, after a cup of coffee. It’s all book-keeping …

@carlo1 - here is a start - see if that does what you need. So far it leaves one parent layer at the top level; I’ll see about getting rid of that.

ConsolidateLayers.py (1.5 KB)

@carlo1 - I made a change so that the script will run correctly with any layer set as current if there is at least one layer with no child layer.

To use the Python script use `RunPythonScript`, or a macro:

`_-RunPythonScript "Full path to py file inside double-quotes"`

-Pascal

Oh but also, some layers might be like this:

-Exploded block 1

-Finish 1
-2mm Steel
-3mm Steel

-Assembly 1
-Finish 2
- 2mm steel
-3mm steel
-18mm MDF

Does this make things considerably harder?

Oh wow amazing.

I’m sure I’m not the only person longing for such a script

Thank you so much

Carlo

Hi @pascal.

Sorry for the delay and thanks for the script!

Maybe I’m not running this correctly, it seems to think about it and do a few layers. Is there a way i can send you a file as a test bed?

I cant post it on the forum as its confidential

Thanks Carlo

Hi Carlo- PM me with the file - my guess is maybe a layer is set current that is blocking things, but I’ll take a look.
-Pascal

1 Like

Is it possible to move all sublayers to top level in a macro? I am flattening our files so this is a step to having all the cut files end up at the top level. I then purge out the top layers which have no objects on them. Thanks

I have this script in my library you can try…

FlattenLayers.py (1.2 KB)

Hi Everyone & @pascal Thanks for taking time to reply to this.

I’ve actually found an annoyingly simple and robust work around after months of thinking about it.

it works for us even if you’ve completely messed up your laying system.

in this picture it shows grasshopper selecting every object that is on or below a layer with “M1” in its layer name.

From here, i can do what ever i want with the objects very easily, like put them on a new layer called M1

Cheers!