Copy link to clipboard
Copied
I need to write a script that simply selects the next artboard.
I have tried a few scripts along the lines of: "var doc = app.activeDocument;
var artboards = doc.artboards;
var activeArtboard = doc.activeArtboard;
var nextArtboardIndex = activeArtboard.index + 1;
if (nextArtboardIndex < artboards.length) {
artboards[nextArtboardIndex].activate();
} else {
artboards[0].activate();
}"
Hi @Deny32888020duo3, here is one approach:
var doc = app.activeDocument;
var currentIndex = doc.artboards.getActiveArtboardIndex();
var nextIndex = (currentIndex + 1) % doc.artboards.length;
doc.artboards.setActiveArtboardIndex(nextIndex);
- Mark
Copy link to clipboard
Copied
Hi @Deny32888020duo3, here is one approach:
var doc = app.activeDocument;
var currentIndex = doc.artboards.getActiveArtboardIndex();
var nextIndex = (currentIndex + 1) % doc.artboards.length;
doc.artboards.setActiveArtboardIndex(nextIndex);
- Mark
Copy link to clipboard
Copied
Thank you! This seems to sucessfully select the next artboard starting with 1. Though it does not change the selection the the Artboard panel it does select the next artboard on the screen!
Copy link to clipboard
Copied
Yes I noticed that and even using app.redraw() didn’t update it. Still, it otherwise does the job.
Copy link to clipboard
Copied
It's an old bug. Probably with the advent of CC versions of Illustrator, because in CS5/CS6 the Artboards panel also changed.
My note about this: https://aiscripts.medium.com/active-artboard-display-120c69c48547