Copy link to clipboard
Copied
I was wondering if it is possible to make an action that will make the current artboard(sizes will vary from artwork to artwork) add an inch to the top and and inch to the bottom. I'm making digital murals for wallcovering, and put installation information on the top and bottom of each file. But each wall and each job the dimensions are different. Thanks
Copy link to clipboard
Copied
You could create an action to enlarge the artboard by tricking Illustrator with a rectangle.
Draw a rectangle that is exactly the same size as the original artboard. Select the rectangle and start the Action. Since the artboard size will vary, do not type a specific measurement. Instead use '+ 1' for W and H, and let Illustrator do the math.
Then choose Object > Artboards > Fit to Artwork Bounds.
Optionally, you could delete the rectangle.
End the Action.
Copy link to clipboard
Copied
Doesn't save me a step just makes me take a different step. Might actually take longer. Currently I just go to the artboard and type +2 in the height.
Copy link to clipboard
Copied
I'm trying to do this, but the following won't show up in the action: Object > Artboards > Fit to Artwork Bounds.
It just pretends I did not click the function. What do I have to do to get it to work?
Copy link to clipboard
Copied
To get that command into an action, you have to go to the Actions panel menu and choose 'Insert Menu Item' to get it into the script.
Copy link to clipboard
Copied
I found this question trying to batch resize over 1000 SVG. I could use an action to resize the content, but not to change the size of the artboard. The solution I found worked because SVG files are text based. I used a text editor that supports finding and replacing strings across multiple files. In my case the originals were 32 x 32 px and I needed them to be 20 x 20 px. I replace every instance of `0 0 32 32` in all 1015 SVG files with '0 0 20 20'. That got me half way. Then I had to run a batch action to select all and align to center / middle of artboard. Thought I would drop this here in case anyone can save their files to SVG or already have SVG files to work with.
Copy link to clipboard
Copied
This script will resize the first item in an AI file to a size defined by the user and center the resulting object on the first artboard. It could be simplified and be used in a loop to do multiple files.
resizeContent(20);
function resizeContent(targetWidth) {
var aDoc = app.activeDocument;
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
var myItem = aDoc.pageItems[0];
//Show top page item width
alert('Current object width is ' + myItem.width + ' Points')
//Set target width
targetWidth = prompt('Set target width in Points', targetWidth);
//Calculate scale factor
var myScale = targetWidth / myItem.width;
//Get first artboard width and height
var myAB = aDoc.artboards[0];
var R = myAB.artboardRect[2];
var B = myAB.artboardRect[3];
//Scale top object by scale factor
myItem.width = myItem.width * myScale;
myItem.height = myItem.height * myScale;
//Reposition object to center of artboard
myItem.position = [R / 2 - (myItem.width / 2), B / 2 + (myItem.height / 2)];
}
Copy link to clipboard
Copied
This basic script will add 1 inch to top and bottom of the first artboard in the file.
Download the "resizeArtboard.jsx" file and, if on Mac, put it in "Applications>Adobe Illustrator [version]>Presets>Scripts" then restart Illustrator. It should appear in menu: "File>Scripts>resizeArtboard".
https://www.dropbox.com/s/o2cnnaawqzo6cx1/resizeartboard.jsx?dl=0
Actual Script:
resizeArtboard(72, 72);
function resizeArtboard(top, bottom) {
var aDoc = app.activeDocument;
app.selection = null;
var myAB = aDoc.artboards[0];
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
var T = myAB.artboardRect[0];
var L = myAB.artboardRect[1];
var R = myAB.artboardRect[2];
var B = myAB.artboardRect[3];
myAB.artboardRect = [T, L + top, R, B - bottom];
}
Edit: If you want to set the amount to add in the script use this version. A dialog appears giving you the chance to edit the amount to be added (default is 1 inch). Decimals and negative numbers are accepted.
resizeArtboard2(1);
function resizeArtboard2(amount) {
var aDoc = app.activeDocument;
amount = prompt('Set amount to add to top and bottom (Inches)', amount);
amount = (amount*72);
app.selection = null;
var myAB = aDoc.artboards[0];
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
var T = myAB.artboardRect[0];
var L = myAB.artboardRect[1];
var R = myAB.artboardRect[2];
var B = myAB.artboardRect[3];
myAB.artboardRect = [T, L + amount, R, B - amount];
}
Copy link to clipboard
Copied
This script is great. Is there a way to add an inch to the left and right of the artboard as well (not just top and bottom)?
Copy link to clipboard
Copied
Fixed the indexes of the top and left coordinates of the artboard.
resizeArtboard(1);
function resizeArtboard(amount) {
var aDoc = app.activeDocument;
amount = prompt('Set amount to add to top and bottom (Inches)', amount);
amount = (amount * 72); // pt to inch
var myAB = aDoc.artboards[0];
var L = myAB.artboardRect[0];
var T = myAB.artboardRect[1];
var R = myAB.artboardRect[2];
var B = myAB.artboardRect[3];
myAB.artboardRect = [L - amount, T + amount, R + amount, B - amount];
}