• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Turn selected AI sublayers into top-level layers?

Guest
Jun 05, 2008 Jun 05, 2008

Copy link to clipboard

Copied

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?
TOPICS
Scripting

Views

122.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 15, 2008 Aug 15, 2008
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-leve...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 12, 2013 Jun 12, 2013

Copy link to clipboard

Copied

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;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 25, 2014 Aug 25, 2014

Copy link to clipboard

Copied

Hi, Carlos.

I tried using your script following your instructions but the sublayers name only change to "<Layer>"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2014 Aug 25, 2014

Copy link to clipboard

Copied

the sublayer will copy the name of the first object, if this object has no name, the layer takes the default name "<layer>"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2014 Aug 27, 2014

Copy link to clipboard

Copied

Thanks for the quick response Carlos.  But I selected and previusly named the respective layer and then run your script and still get in return only the "<Layer>" name.

I copied your script in a Note Block document and save it as an .jsx document.  Then run it in Ilustrator CC (17.0) from the File Menu / Scripts / Other Scripts...

Am I doing it wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 27, 2014 Aug 27, 2014

Copy link to clipboard

Copied

The object in the layer needs to be named, the script will get that name and apply it to the layer

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 26, 2014 Sep 26, 2014

Copy link to clipboard

Copied

Carlos, thanks for your renameSublayers script.  Would it be possible to modify it so that it also works with text objects that have not been manually named by the user? I have about a hundred sublayers called Layer 1, Layer 2 etc and inside each one is a single text object such APPLE, PEAR etc which derive their names from the actual text itself - your script cannot seem to see these names unless I manually rename the text objects in the layer panel. Hope that makes sense. Steve

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2014 Sep 26, 2014

Copy link to clipboard

Copied

yes, this version works with either Named or Unnamed text items

// carlos canto // 09/26/14

// https://forums.adobe.com/thread/287812

var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

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

    var sublayer = ilayer.layers;

    sublayer.name = sublayer.pageItems[0].name || sublayer.pageItems[0].contents;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 26, 2014 Sep 26, 2014

Copy link to clipboard

Copied

This is brilliant! Thanks so much. Dealing with long lists of words (separated into text objects) that I need to separate into Layers for After Effects. Much easier to work with them in AE if they have WYSIWYG layer names.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 13, 2015 Jan 13, 2015

Copy link to clipboard

Copied

Hi Carlos

I've saved the script and tried to run it, but I'm getting this error:

error.jpg

this is a screen cap of my file structure

layer_screencap.jpg

so I grabbed my Layer 50, did a release to layers, and have what you see above.  I then selected Layer 50, and tried to run the script and got the error.  Can you give me some guidance in what I'm doing wrong?

Thanks!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2015 Jan 14, 2015

Copy link to clipboard

Copied

you're not doing anything wrong, the script was meant to be used for text items only, it seems you have paths in layer 51

try this version

// http://forums.adobe.com/thread/877442?

// http://forums.adobe.com/thread/1408454?tstart=0

// carlos canto // 09/26/14

// https://forums.adobe.com/thread/287812

var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

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

    var sublayer = ilayer.layers;

    sublayer.name = sublayer.pageItems[0].contents || sublayer.pageItems[0].name;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

Carlos - you are a legend. Thanks dude, you've saved me A LOT of time!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 05, 2016 Apr 05, 2016

Copy link to clipboard

Copied

This ancient thread is still very relevant. I used the script from post #6 and now have a nice top-level layered AI file that I can import into After Effects. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

Thanks Carlos.  Unfortunately, I'm still having trouble with it, but I think it might be due to the fact that the files I deal with are a mixture of text and paths.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

can you share a file? if so, upload it to your favorite host and post a link here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2015 Jan 28, 2015

Copy link to clipboard

Copied

Unfortunately, I can't post an actual file because it's confidential, but I'll see if I can find some time to build something similar to post up here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 28, 2015 Jan 28, 2015

Copy link to clipboard

Copied

Hi Murgiddy,

I've just had a go using a mixture of paths and texts (threw in a rectangle for good measure) and it all seemed to work fine.

These are my steps:

Before

Release to layers (with Top layer and circle highlighted)

Select Top layer again (again with circle selected)

File -> Scripts -> Other Scripts - select the exceptionally handy script Carlos has made

Layers now named after their sub layer name

Are you doing anything differently?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2015 Jan 28, 2015

Copy link to clipboard

Copied

cubkent,

That worked for me!  I'm not exactly sure what I was doing differently before (possibly not having the circle selected???) but it appears to be working now.  I guess I just needed to follow it step by step...I'm a CG artist, so AI isn't my strongest software

Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 28, 2015 Jan 28, 2015

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 28, 2015 Jan 28, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 16, 2015 Mar 16, 2015

Copy link to clipboard

Copied

Hi guys, Im joining to this thread.


I use carlos' loop to set the sub-layers to top-layers, and its works very well.

My problem/question:

Has anyone found a script-command to make the "release to layers" task automatically? (It is necessary for my main script, I cant do it manually.)

Something like:

app.executeMenuCommand('COMMAND HERE');


Maybe its just 'releasetolayers', but I have no english version of Illustrator here, so please tell me, if my approach is correct.

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2015 Mar 16, 2015

Copy link to clipboard

Copied

there may not be a command string for release to layers, as an alternative, you could record an Action, then have your script run the action to release to layers.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2015 Mar 17, 2015

Copy link to clipboard

Copied

Thanks carlos,

that might work.
I didnt know about the app.doScript() function before.

I will test this scenario.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2016 Jun 19, 2016

Copy link to clipboard

Copied

Carlos - Thanks for this script. Amazing!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Thanks CarlosCanto, this is fantastic! May I share this script with colleagues? I just copied all your lines of code and would send them the jsx file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Sure Rene Andritsch​, go adhead

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines