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

Sort layers (with sublayers) in Illustrator as they appear (top to bottom)

New Here ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

Hi all,

I'm really hoping someone can help me out. I need a script that sorts layers (with sublayers) in Illustrator as they appear on the artboard (top to bottom).
I have a selection of colour swatches that I need to keep in the correct order, as you can see in the layers panel they don't match how my current artwork looks.

I understand I could manually arrange these within the layers panel, however sometimes I'll be working with over 500 swatches.

Any help would greatly be appreciated.

Thanks, Sammy

Screen Shot 2019-01-16 at 14.47.38.png

TOPICS
Scripting

Views

1.7K

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
Adobe
Community Expert ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

Are you looking for some help writing the code? Or are you looking for someone to write it?

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 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

I‘m a complete novice so would need help writing it or if you could point me in the direction of ‘getting to know the basics‘ of Illustrator scripting. It’s something I’d really like to learn for myself.

Looking at other scripts out there for putting layers in alphabetical order I kinda understand it, but for what I’m looking to do I’m thinking I’d need to base it on the position of the vector based on its x and y position?

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 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

do you have any programming experience? just so i know where to start pointing you.

basic procedure for what you're looking to do would be this:

gather the items that need to be sorted (the swatch squares in your screenshot above).

sort the items by their y (or top) coordinate and place the sorted results into a new array

loop the sorted array to organize the items in the layers panel

     (you could do this eitehr with zOrderPosition or with a simple bring to front or send to back command)

the above might actually live inside it's own function so that you can just feed it any kind of layer (top level or sublayer).

Depending upon how clean and predictable your file will be, this could be a very easy task, or a complicated process designed to filter out potential errors. There's no way to know really without looking at the file(s)

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 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

I don't have any programming experience. I've managed to add pre made scripts and tweak them a little. Other than that, none I'm afraid.

The files will always be exactly as my above screen shot. 

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 17, 2019 Jan 17, 2019

Copy link to clipboard

Copied

Ok. if you have no programming experience as yet, you'll probably want to start with a basic javascript tutorial. I usually recommend codecademy.com. (it's free!)

If you go through their javascript "course" you'll get a decent understanding of basic syntax and programming logic. After that it would be time to start taking a look at the Illustrator JavaScript API to learn how to utilize the logic you learned to manipulate illustrator. Any specific questions you have, i'm more than happy to answer. But i'd start at codecademy first if you intend to learn how to write scripts for illustrator.

good luck. 😃

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 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

Thank you for your help and advice.

I've looked into several courses to learn JavaScript, but unfortunately its hugely outside of my understanding and I don't have the free time available to dedicate to it at the moment.

Thank you again for taking the time to read/reply to my post.

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 ,
Jan 07, 2020 Jan 07, 2020

Copy link to clipboard

Copied

LATEST

I had the same problem and I found working script in first massage here: Optimize objects stacking order for vinyl cutting.
Change BRINGTOFRONT to SENDTOBACK if you need to reverse order.

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