Skip to main content
June 6, 2008
Answered

Turn selected AI sublayers into top-level layers?

  • June 6, 2008
  • 18 replies
  • 127302 views
Hi, all!

I wanted to ask if by chance any of the scripting gurus here happen to have written an AI script that will take a number of selected sublayers/sub-sublayers and move them so they become top-level layers?
I am really needing this very badly, given that After Effects can only handle AI layers as separate entities. So I find myself moving tens, even hundreds of nested sublayers to the top level all the time.
Is it possible this script exists already?
This topic has been closed for replies.
Correct answer JETalmage
This .zip archive contains an AICS3 file and a draft script.

Install the script.
Launch Illustrator.
Open the AI file.

Note that an expanded Blend is on the Artboard. Each object from the former Blend is on its own Layer. The Layers palette contains 100 or so Layers, all named sequentially and nested 10 levels deep.

Run the script a few times. Each time the script runs, an alert tells you the number of existing top-level Layers. It then moves any sublayers nested inside each of those top-level Layers so that they are top-level Layers.

After you have done this for the number of times necessary in the example, you should see that all the Layers are top-level, and still have the correct stacking order (verified by the correct order of the overlapping paths on the Artboard).

Again, this is just rough and experimental. This is the only file I have tried it on; but I think it should work on any file, given that there are no loose objects inside the subLayers as you described. Also, it does not operate on only selected Layers, as your original post specifies. Perhaps it will help as a starting point.

JET

18 replies

renél80416020
Inspiring
May 25, 2020

Bonjour à tous!
Félicitation JET pour ce script qui est très réfléchi, dans la mesure où les calques se retrouvent tous dans le bon ordre, (1 à 102).
Je n'utiliserez certainement pas ce script mais merci pour ce qu'il m'a apporté, j'ai enfin un peu compris l'utilisation de ElementPlacement.PLACEAFTER.
je ne voyait pas comment l'utiliser. (si vous avez d'autres exemples d'application et aussi avec PLACEBEFORE?).

Si on m'avait demandé de faire ce script, j'aurais utilisé move(currLayer.parent...
mais l'ordre n'est pas toujours bien respecté.

René

PS Je me suis permis de modifier le script pour tout traiter en seule une exécution. testé sur CS6)

 

 

New Participant
June 1, 2018

found a non-script answer:

https://www.youtube.com/watch?v=AAESBjlo1-o

Select toplevel layer. select release to layers. Shift drag sublayers out the top layer.

(from 'learning illustrator')

JaySprout
Inspiring
May 16, 2017

I'm having a much simpler (and, thus, far more infuriating) problem. I can't drag the sublayers out of the top layer. That's all I need. I have one layer with a bunch of sub-layers. If I drag up, no matter how carefully or slowly (sometimes I see a plus-sign next to my pointer) nothing happens. If I drag down to an "open" part of the layers panel, I only get the "no" sign. What am I doing incorrectly or not doing at all? In 17 years of using Illustrator I've never needed to do this until learning After Effects. Yes, I said that just to point out I'm not a total newb.

CarlosCanto
Adobe Expert
May 16, 2017

that's strange, dragging down onto the big empty space in the layers panel should move your sublayers down to the bottom of the stack. If you see a plus sign when you dragged up, you went to far.

try adding an empty layer on top of your main layer to see if it's easier to move the sublayers out and place them in between the 2 main layers.

you're not doing anything wrong, it just seems illustrator is not working right.

Larry G. Schneider
Adobe Expert
May 16, 2017

Consider the possibility that all the things are just objects and not sublayers. They cannot be dragged out of the single existing layer.

georgem92621476
New Participant
September 15, 2016

This one is not optimal but worked for me:

My problem was that I had a sublayer which include a big bunch of my objects but not all and I wanted to get them all into one. But AI can merge layers only of the same level. So I did the following (MAC):

1. Click all objects on layer but not sublayer. You can do this by

          a. clicking the name of the top object and then scroll down to the last object and click the name of the object while holding shift

2. From the layers menu, select Collect in new layer 

3. Then click the name of the sublayer you had before, hold shift and click the name of the new sublayer

4. Select Merge Selected from the layers menu

If there are too many objects in 1 and your mac freezes while selecting objects (as in my case), repeat this multiple times (ps. You can merge multiple layers (of the same level) in once)

Hope it helps. Not too sure it solves the initial problem exactly. But it surely gives you some hints.

Best.

New Participant
July 12, 2016

Here is a solution to the problem! Hope this is what you were looking for! It helped me out when I was trying to create artwork for a motion graphic.

Illustrator How to turn sublayers into layers - YouTube

maseintheplace
New Participant
July 20, 2015

Thanks Carlos - this is brilliant!

After a few goes, I finally figured it out...

-I only needed to select the top layer

-I had to run the name script 1st

thanks again - saved me a ton of time

CarlosCanto
Adobe Expert
July 20, 2015

you're welcome

georginap4781
New Participant
March 5, 2015

Hi all, the basic moving of sub layers to top layers was baffling me too,  I got it working by having the top layer open to reveal the compound paths underneath first, THEN realease to layers,  you can see them change from compound paths to layers and then you can move them, or at least this is the only new thing I tried and then it worked for me hope this helps others

New Participant
November 20, 2014

Hi, i am sorry but I not an expert in AI and i still can´t make it... How can I turn all the sub layers in top layers?

CarlosCanto
Adobe Expert
November 20, 2014

see post # 16, if you don't need the new layers renamed, skip step # 1.2 (running the script)

New Participant
November 20, 2014

Ok. I understand the script part and i was already able tanks to you to make all those layers top level. But i will work in AE later and it would be great to have the same names they had back when it was all sublayer. Its possible? Thank you so much!

James Gifford—NitroPress
Brainiac
September 2, 2014

None of the above is working for me and every search brings me back to this same thread.

Simple enough: I have a CC file later opened in CC/2014. It's just a logo with a colored background and a type string, with the type backed up by black shapes and outline shapes so I can pull it into AE and do some simple animation.

Using repeated tries with the "Release to Layers {Sequence)" command, and reverting and starting over each time things didn't end up where I wanted them, I finally have all the layers in one sublevel array... but I CANNOT get them to the top level. Using RtL(S) just encapsulates them one level down, solving nothing.

WHY has it become so hard/impossible to move layers from sublayer levels to the top layer, when going the other way is completely intuitive and most operations create sublayers? More to the point, how can I get my sublayers all to the top level when none of the above processes work?

CarlosCanto
Adobe Expert
September 3, 2014

can you share a file? or post screen shots showing your layers exactly the way Larry did in post # 12

James Gifford—NitroPress
Brainiac
September 3, 2014

I could, but let me rephrase it as a simple question:

  • Create a new document with four layers.
  • Put one graphic element on each layer.
  • Drag three layers under one, making them into child layers.

Now... how do you restore those three layers to top-level status? Everything I've tried either fails or (in the case of "Release to Layers") buries them in a deeper subset of new layers.

Is the top level to child layer change not reversible (in CC and CC/2014, at least)?

New Participant
June 12, 2013

I had the same problem. In Illy CS6, I found a way though.

  1. Release layers (sequence).
  2. Select them all by clicking on the top sub-layer, hold shift and click on the bottom sub-layer.
  3. Drag the whole bunch above the top-level layer they're in. They will all turn into top-level layers.

Unfortunately, the release to layers command doesn't name the sub-layers according to the objects they're in. Aynone has a fix for that?

CarlosCanto
Adobe Expert
June 13, 2013

here's a script to rename Sublayers (based on the first object's name), do it like this

1. release layers (ie Layer 1)

1.1 activate (highlight) layer (Layer 1)

1.2 run script

2. select them all...

3. drag the whole bunch...

// renameSublayers.jsx - carlos canto

// http://forums.adobe.com/message/5403549?tstart=0#5403549

var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

for (i=0; i<ilayer.layers.length; i++) {

    var isublayer = ilayer.layers;

    isublayer.name = isublayer.pageItems[0].name;

}

CarlosCanto
Adobe Expert
January 29, 2015

No problem, yeah I was having issues until I selected everything I could about the layer! Glad it's working for you know.

Thanks again Carlos.


you're welcome, glad to hear it's working for everyone now, thanks for helping out with screen shots.