Copy link to clipboard
Copied
Hello, I need a script that will duplicate artboards. It's important that as soon as I run the script a window will open asking how many times to duplicate. If you enter 0, then nothing will be duplicated.
Hi,
Try follwing snippet
#target illustrator
function duplicateArtboard() {
var dlg = new Window("dialog", "Duplicate Artboard");
row = dlg.add('group', undefined, '');
row.add('statictext', undefined, "Times: ");
var timesInput = row.add('edittext', undefined, "");
var duplicateButton = row.add('button', undefined, 'Duplicate', {
name: 'Duplicate'
});
duplicateButton.onClick = function () {
var _numberOfTimes = Number(timesInput.text);
if
...
Copy link to clipboard
Copied
Hi,
Try follwing snippet
#target illustrator
function duplicateArtboard() {
var dlg = new Window("dialog", "Duplicate Artboard");
row = dlg.add('group', undefined, '');
row.add('statictext', undefined, "Times: ");
var timesInput = row.add('edittext', undefined, "");
var duplicateButton = row.add('button', undefined, 'Duplicate', {
name: 'Duplicate'
});
duplicateButton.onClick = function () {
var _numberOfTimes = Number(timesInput.text);
if (_numberOfTimes != 0) {
for (var i = 0; i < _numberOfTimes; i++) {
var doc = app.activeDocument;
var thisBoardIndex = doc.artboards.getActiveArtboardIndex();
var thisBoard = doc.artboards[thisBoardIndex];
var thisRect = thisBoard.artboardRect;
var lastBoard = doc.artboards[doc.artboards.length - 1];
var lastRect = lastBoard.artboardRect;
doc.selectObjectsOnActiveArtboard();
app.copy();
var newBoard = doc.artboards.add(thisRect);
var offsetH = 20;
newBoard.artboardRect = [
lastRect[2] + offsetH,
lastRect[1],
lastRect[2] + offsetH + (thisRect[2] - thisRect[0]),
lastRect[3]
];
newBoard.name = thisBoard.name + " copy";
app.executeMenuCommand("pasteFront");
doc.selection = null;
}
}
dlg.close();
};
dlg.show();
};
duplicateArtboard();
Copy link to clipboard
Copied
Thank you!
Now I have another request.
I need to insert cards that will fill the entire height of the sheet (30 cm)
Is it possible to give the value of a desired number of cards, and the script will duplicate to a maximum of cards that go in height?
I will give 3 examples for you to understand:
1. If I need 5 cards 5 cm high, the script will duplicate me 6 cards, because 5 * 6 is 30.
2. If I need 3 cards 5 cm high, the script will also duplicate me 6 cards because 5 * 6 is 30.
3. If I need 7 cards 5 cm high, the script will duplicate me 12 cards.
Attached is a diagram for example 3.
That is, always take advantage of the height of the sheet
To the maximum.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now