Multiple artboards to multiple layers
Hello everyone, I have this script to convert multiple layers to multiple artboards, and also copy each layer name to artboards.
The problem is how to reserve the this script process?
I mean to converts artboards to layer and copy artboards name to layer. Thanks
#target illustrator
main();
function main() {
if ( app.documents.length == 0 ) { return; }
var doc = app.activeDocument;
doc.layers[0].hasSelectedArtwork = true;
doc.fitArtboardToSelectedArt( 0 );
doc.selection = null;
for ( var i = 1; i < doc.layers.length; i++ ) {
doc.artboards.add( [0,0,72,-72] );
doc.layers[i].hasSelectedArtwork = true;
doc.fitArtboardToSelectedArt( i );
doc.selection = null;
};
};
if (app.documents.length == 0) {
alert("No Open / Active Document Found");
} else {
var doc = app.activeDocument;
if (doc.artboards.length == doc.layers.length && doc.layers.length == doc.artboards.length) {
for (var i = 0, l = doc.artboards.length; i < l; i++) {
var ab = doc.artboards[i];
ab.name = doc.layers[i].name;
}
alert("Finished:\nRenaming of Artboards to match Layer names is complete");
} else {
alert("Opps: This wont work!\n The number of Layers and Artboards do not match");
}
}
