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

reverse artboards order

Explorer ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

Hi. 

I found a script online that converts the order of the artboards.
here:

/ reverseArtboardsOrder.jsx
// carlos canto
// http://graphicdesign.stackexchange.com/questions/64865/is-there-a-way-to-automate-reversing-the-order-of-artboards-in-illustrator

function reverseArboardsOrder () {
    var idoc = app.activeDocument;
    var abs = idoc.artboards;
    var abcount = abs.length; 

    var abNames = [];    
    var abRects = [];

    for (i=0; i<abcount; i++) {
        abNames[i] = abs[i].name; 
        abRects[i] = abs[i].artboardRect;
    }

    for (j=0, k=abcount-1; j<abcount; j++, k--) {
        var abRect = abRects[k]; 
        idoc.artboards.remove(k); 
        var newab = idoc.artboards.add(abRect);
        newab.name = abNames[k]; 
    }
    idoc.rearrangeArtboards();
}

reverseArboardsOrder();


The problem is that if there is only one artboard, it gives an error.
I combine such a script in a wider script, so I ask if anything can fix this script for me that if there are one artboards, it will be ignored and will not give an error.

TOPICS
Scripting

Views

298

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

Guide , Feb 20, 2021 Feb 20, 2021
// reverseArtboardsOrder.jsx
// carlos canto
// http://graphicdesign.stackexchange.com/questions/64865/is-there-a-way-to-automate-reversing-the-order-of-artboards-in-illustrator

function reverseArboardsOrder () {
    var idoc = app.activeDocument;
    var abs = idoc.artboards;
    var abcount = abs.length; 

if (abs.length > 1) {

    var abNames = [];    
    var abRects = [];

    for (i=0; i<abcount; i++) {
        abNames[i] = abs[i].name; 
        abRects[i] = abs[i].artboardRect;
    }

 
...

Votes

Translate

Translate
Adobe
Guide ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

// reverseArtboardsOrder.jsx
// carlos canto
// http://graphicdesign.stackexchange.com/questions/64865/is-there-a-way-to-automate-reversing-the-order-of-artboards-in-illustrator

function reverseArboardsOrder () {
    var idoc = app.activeDocument;
    var abs = idoc.artboards;
    var abcount = abs.length; 

if (abs.length > 1) {

    var abNames = [];    
    var abRects = [];

    for (i=0; i<abcount; i++) {
        abNames[i] = abs[i].name; 
        abRects[i] = abs[i].artboardRect;
    }

    for (j=0, k=abcount-1; j<abcount; j++, k--) {
        var abRect = abRects[k]; 
        idoc.artboards.remove(k); 
        var newab = idoc.artboards.add(abRect);
        newab.name = abNames[k]; 
    }
    idoc.rearrangeArtboards();
}

}

reverseArboardsOrder();

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 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

LATEST

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