There is getActiveArtboardIndex
and setActiveArtboardIndex
, I can get the Artboard
object with getByName
.
But how do I set active artboard by name?
Or at least get index from the Artboard
object?
Not the most elegant way, but still solves the problem:
var docRef = app.activeDocument;
var ABName = "Artboard Name";
function setActiveArtboardBy(name) {
var artboard = docRef.artboards.getByName(name);
for (i = 0; i < docRef.artboards.length; i++) {
if (docRef.artboards[i] == artboard) {
docRef.artboards.setActiveArtboardIndex(i);
break;
}
}
}
setActiveArtboardBy(ABName);