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

Sort artboards by name

Explorer ,
Feb 07, 2012 Feb 07, 2012

Copy link to clipboard

Copied

We have over 50 artboards in most of our documents.  Is there a way to sort the artboards as listed in the artboards panel by name via script?

TOPICS
Scripting

Views

4.6K

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

Community Expert , Feb 21, 2012 Feb 21, 2012

do you still need it? here's a script, it only works with numbers for now, it needs more work if there are alpha characters in the artboard names.

#target illustrator

// script.name = sortArtboardsNumericallyCS5only.jsx;

// script.description = reArranges the Artboards indexes (for now works with Numbers only)

// script.required = an open document with at least 2 artboards, CS5 only;

// script.parent = CarlosCanto; // 2/21/12;

// script.elegant = false;

var idoc = app.activeDocument;

var abs = idoc.artb

...

Votes

Translate

Translate
Adobe
Explorer ,
Feb 09, 2012 Feb 09, 2012

Copy link to clipboard

Copied

Anyone have any ideas on this?

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
Guru ,
Feb 09, 2012 Feb 09, 2012

Copy link to clipboard

Copied

I don't think that there are any methods for doing this…

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 ,
Feb 09, 2012 Feb 09, 2012

Copy link to clipboard

Copied

No way with actions, javascript, vb or any other means to automate this task? Holding out hope if anyone has any ideas J

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
Guru ,
Feb 09, 2012 Feb 09, 2012

Copy link to clipboard

Copied

Tim, artboards are pretty new the to AI the fact that script has access to any of this is nothing short of of a miracle… There are some things that have been about much longer and still no access… With artboards you can add() Remove() and Insert() plus get/set the active one… You can also rearrange but this is the actual location in terms of the document NOT the order positioning in the GUI palette.

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 ,
Feb 21, 2012 Feb 21, 2012

Copy link to clipboard

Copied

do you still need it? here's a script, it only works with numbers for now, it needs more work if there are alpha characters in the artboard names.

#target illustrator

// script.name = sortArtboardsNumericallyCS5only.jsx;

// script.description = reArranges the Artboards indexes (for now works with Numbers only)

// script.required = an open document with at least 2 artboards, CS5 only;

// script.parent = CarlosCanto; // 2/21/12;

// script.elegant = false;

var idoc = app.activeDocument;

var abs = idoc.artboards;

var abcount = abs.length; // save the artboard count

var absNames = []; // array to hold artboards names

for (i=0; i<abcount; i++) {

    absNames = abs.name; // get all artboard names in an array

}

absNames.sort(function (a,b) { return a-b }); // sort Numerically

// duplicate all artboards, in order according to the sorted array

for (j=0; j<abcount; j++) {

                        var newAB = idoc.artboards.add(abs.getByName(absNames).artboardRect); // duplicate AB, which one? go by the sorted array

            newAB.name = absNames; // rename artboard

}

// delete original set of artboards

for (k=abcount-1; k>=0; k--) {

        idoc.artboards.remove(k);

}

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 ,
Feb 22, 2012 Feb 22, 2012

Copy link to clipboard

Copied

What a lifesaver! This is great…all of my artboards are named by numbers, so it’s absolutely perfect for our use.

Thanks so much!

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 12, 2012 Mar 12, 2012

Copy link to clipboard

Copied

I just ran into the 100 artboard limit, when I have a document with 51 or more artboards.  Because the script duplicates every artboard, it puts me over 100 temporarily and causes the script to fail.  I don't see a way around this at the moment, do you?

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 12, 2012 Mar 12, 2012

Copy link to clipboard

Copied

good point...let me think about 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
Guru ,
Mar 12, 2012 Mar 12, 2012

Copy link to clipboard

Copied

Does this do it…?

#target illustrator

function sortArtboards() {

 

          if ( app.documents.length == 0 ) { return; }

          var i, obj, doc, count, list;

 

          doc = app.activeDocument;

 

          count = doc.artboards.length; // Original length

 

          doc.artboards.insert( doc.visibleBounds, count ); // At end

 

          app.redraw();

 

          list = Array();

 

          // All but the new one…

          for ( i = count-1; i >= 0; i-- ) {

 

                    obj = Object();

                    obj.abname = doc.artboards.name;

                    obj.abrect = doc.artboards.artboardRect;

                    //obj.abindex = i;

                    list.push( obj );

 

                    doc.artboards.remove( i );

 

          };

          list.sort( function ( a, b ) { return a.abname - b.abname } );

          //$.writeln( list.toSource() );

 

          for ( i = 0; i < count; i++ ) {

 

                    doc.artboards.insert( list.abrect, i );

                    doc.artboards.name = list.abname

 

          };

          doc.artboards[count].remove();

 

};

sortArtboards();

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 14, 2012 Mar 14, 2012

Copy link to clipboard

Copied

Works perfectly.  Thanks so much for the help!

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
Guru ,
Mar 15, 2012 Mar 15, 2012

Copy link to clipboard

Copied

Tim my guess was that this is just for PDF page order? You can however add this…

doc.rearrangeArtboards( DocumentArtboardLayout.GridByRow, 3, 144, true );

And it moves the artboards about in the doc too…

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 15, 2012 Mar 15, 2012

Copy link to clipboard

Copied

We’re very systematic. It was actually just so we can go to the same place on all of our hundreds of master files and get to the same product. Our artboards are all different sizes, and there are about 50ish of them, so this addition didn’t work. It said the re-arrangement would put artboards outside of the canvas range. Thanks again so much for your help, as always.

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
Guru ,
Mar 15, 2012 Mar 15, 2012

Copy link to clipboard

Copied

Yeah… I've seen one of your 50 artboard files… And doubted it would work there… It was of interest to me and my experiments on a test file though… may prove usefull to others to know…

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 ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

Hi,

Just refreshing the thread. This script would be very useful for arranging Artboards by 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
Participant ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

LATEST

This script works for me.

 

#target illustrator

var doc = app.activeDocument;
var artboards = doc.artboards;
var artboard_count = artboards.length; // save the artboard count
var artboard_names = []; // array to hold artboards names

for (i=0; i<artboard_count; i++)
{
    artboard_names.push(artboards[i].name);
}

artboard_names.sort();

for (j=0; j<artboard_count; j++)
{ 
    var aname = artboard_names[j];
    var rect = artboards.getByName(aname).artboardRect;
    var newAB = artboards.add(rect); // duplicate AB, which one? go by the sorted array
    newAB.name = artboard_names[j]; // rename artboard
}

// delete original set of artboards
for (k=artboard_count-1; k>=0; k--)
{
    artboards.remove(k);
}

 

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