Copy link to clipboard
Copied
Hi,
I'm a newbie concerning scripting and i need your help.
Here is the situation : In Illustrator CS6, I have one artboard, and a second one, which has the same size than the first. The right side of one is on the left side of the other. Then we can export two .eps files to publish books.
Now, I would like to resize the first artboard as the new size becomes (artboard 0 + artboard 1) by writing a script (because there are a lot of files to work on). Or eventually create a third artboard, whose size is still (artboard0 + artboard1).
The problem is that every file has different artboards : the height can change but the horizontal size stays the same.
Here is my opinion, and 3 alternatives.
-We should write a script which makes the first artboard (artboard 0) twice bigger only to the right side.
-I can't be sure that "artboard 0" is always the one on the left (even if it should be like this), so the best way is to merge both of the artboards, but Im not sure it's possible by scripting.
-Create a third artboard, whose coordonates are the same on left corners of left artboard, end the same on right corners of right artboard.
I hope I've been clear, and that you can help me on that.
Thank you all in advance !
This should create you a NEW artboard that encompasses all others regardless…
...#target illustrator
superArtboard();
function superArtboard() {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var i, doc, artBds, supABd;
doc = app.activeDocument;
artBds = doc.artboards;
supABd = artBds[0].artboardRect;
for ( i = 1; i < artBds.length; i++ ) {
if ( artBds.artboardRect[0] < supABd[0] ) { supABd[0] = artBds.artboardRect[0] }; // Left
if ( artBds.artboardRect
Copy link to clipboard
Copied
This should create you a NEW artboard that encompasses all others regardless…
#target illustrator
superArtboard();
function superArtboard() {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var i, doc, artBds, supABd;
doc = app.activeDocument;
artBds = doc.artboards;
supABd = artBds[0].artboardRect;
for ( i = 1; i < artBds.length; i++ ) {
if ( artBds.artboardRect[0] < supABd[0] ) { supABd[0] = artBds.artboardRect[0] }; // Left
if ( artBds.artboardRect[1] > supABd[1] ) { supABd[1] = artBds.artboardRect[1] }; // Top
if ( artBds.artboardRect[2] > supABd[2] ) { supABd[2] = artBds.artboardRect[2] }; // Right
if ( artBds.artboardRect[3] < supABd[3] ) { supABd[3] = artBds.artboardRect[3] }; // Bottom
};
doc.artboards.add( supABd );
app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;
};
Copy link to clipboard
Copied
Hi pylerayer,
@Muppet Mark gives you the alternative nr.3
Another variant:
Enlarges the first artboard and removed the other.
// ArtboardsMergeAllCompact.jsx
// enlarges the first artboard and removes the other artboards
// regards pixxxelschubser
var aDoc = app.activeDocument;
var AB = aDoc.artboards;
var ABR = AB[0].artboardRect;
for ( i = AB.length-1; i > 0; i-- ) {
ABR[0] = (ABR[0] < AB.artboardRect[0]) ? ABR[0] : AB.artboardRect[0]; // Left
ABR[1] = (ABR[1] > AB.artboardRect[1]) ? ABR[1] : AB.artboardRect[1]; // Top
ABR[2] = (ABR[2] > AB.artboardRect[2]) ? ABR[2] : AB.artboardRect[2]; // Right
ABR[3] = (ABR[3] < AB.artboardRect[3]) ? ABR[3] : AB.artboardRect[3]; // Bottom
AB.remove();
}
AB[0].artboardRect = ABR;
You also get a „superArtboard“ (like in Muppets Marks script) but in the end there is only one artboard in your document.
Have fun
![]()
Copy link to clipboard
Copied
Thank you guys, it works !
I will come back to you if I have more questions.
Bye ![]()
Copy link to clipboard
Copied
Actually, this .jsx script is independant, which means that it perfectly works, but alone. The thing is that I would like to insert it in the pannel Action, because I have more actions to play in a particular order.
Do you know if this is possible and the way i have to do it ?
Thank you,
PY
Copy link to clipboard
Copied
function startRant() {
Yes this is possible… But you are going to bash your head against the longest running ISSUE with AI…
You can use the insert menu item and add the script part to your action…
BUT this ONLY works per AI session… ARGH why has this NOT been addressed in 10 years…???
You will need to relink the script at each and every AI restart…
};
The ONLY workaround at present is to use script as the main processor and call actions for the other parts…
Find more inspiration, events, and resources on the new Adobe Community
Explore Now