Copy link to clipboard
Copied
I have a different size of artboard, I want to record an action to convert the artboard to letter size.
Could easily be done with an action.
Record:
- Create rectangle (letter size)
- H/V align rectangle to artboard.
- Object menu > Artboards > Fit to Selected Art.
- Delete rectangle.
Not the cleanest code, but it's operational...
var docRef = app.activeDocument;
var docRef = app.activeDocument;
var ABs = docRef.artboards;
var choice;
//Creates new Popup
var Pallette = new Window ("dialog", "Artboard Resizer");
Pallette.add ("statictext", undefined, "Pick a size");
Pallette.orientation = "row";
//Dropdown Menu
var myDropdown = Pallette.add ("dropdownlist", undefined, [
"8.5\" x 11\"",
"11\" x 8.5\"",
"12\" x 12\"",
"12\" x 16\"",
"16\" x 12\"",
"24\" x 12\"",
"32\" x 20\""
]);
...
Copy link to clipboard
Copied
As I was educated the other day artboards are not "axction-able", so there's no way to do that. You have to do it manually.
Mylenium
Copy link to clipboard
Copied
Thank you for your response. Appreciated
Copy link to clipboard
Copied
Could easily be done with a script.
Copy link to clipboard
Copied
This is noted. Thank you
Copy link to clipboard
Copied
Could easily be done with an action.
Record:
- Create rectangle (letter size)
- H/V align rectangle to artboard.
- Object menu > Artboards > Fit to Selected Art.
- Delete rectangle.
Copy link to clipboard
Copied
This method worked.
Thank you!
Copy link to clipboard
Copied
Not the cleanest code, but it's operational...
var docRef = app.activeDocument;
var docRef = app.activeDocument;
var ABs = docRef.artboards;
var choice;
//Creates new Popup
var Pallette = new Window ("dialog", "Artboard Resizer");
Pallette.add ("statictext", undefined, "Pick a size");
Pallette.orientation = "row";
//Dropdown Menu
var myDropdown = Pallette.add ("dropdownlist", undefined, [
"8.5\" x 11\"",
"11\" x 8.5\"",
"12\" x 12\"",
"12\" x 16\"",
"16\" x 12\"",
"24\" x 12\"",
"32\" x 20\""
]);
myDropdown.selection = 0
var group3 = Pallette.add("group");
group3.orientation = "row";
//var a = group3.add("radiobutton", undefined, "Single Artboard");
var a = group3.add("radiobutton", undefined, "All Artboards");
var radiobuttons = [a];
a.checkedState = false;
for (var i = 0; i < radiobuttons.length; i++) {
(function (i) {
radiobuttons[i].onClick = function () {
method = radiobuttons[i].text;
};
})(i);
}
var myButtonGroup = Pallette.add ("group");
myButtonGroup.orientation = "column";
var btnCreate = myButtonGroup.add ("button", undefined, "OK");
btnCreate.onClick = function () {
choice = myDropdown.selection.text;
method = radiobuttons[i].text;
w.button.onClick = function () {
w.close();
}
};
Pallette.show ();
var method = method;
if(method == "All Artboards"){
if (choice == "8.5\" x 11\"") {
resizeAllArtboards(8.5 * 72, 11 * 72);
} else if (choice == "11\" x 8.5\"") {
resizeAllArtboards(11 * 72, 8.5 * 72);
} else if (choice == "12\" x 12\"") {
resizeAllArtboards(12 * 72, 12 * 72);
} else if (choice == "12\" x 16\"") {
resizeAllArtboards(12 * 72, 16 * 72);
} else if (choice == "16\" x 12\"") {
resizeAllArtboards(16 * 72, 12 * 72);
} else if (choice == "24\" x 12\"") {
resizeAllArtboards(24 * 72, 12 * 72);
} else if (choice == "32\" x 20\"") {
resizeAllArtboards(32 * 72, 20 * 72);
}}
else {
// new code
if (choice == "8.5\" x 11\"") {
resizeArtboard(8.5 * 72, 11 * 72);
} else if (choice == "11\" x 8.5\"") {
resizeArtboard(11 * 72, 8.5 * 72);
} else if (choice == "12\" x 12\"") {
resizeArtboard(12 * 72, 12 * 72);
} else if (choice == "12\" x 16\"") {
resizeArtboard(12 * 72, 16 * 72);
} else if (choice == "16\" x 12\"") {
resizeArtboard(16 * 72, 12 * 72);
} else if (choice == "24\" x 12\"") {
resizeArtboard(24 * 72, 12 * 72);
} else if (choice == "32\" x 20\"") {
resizeArtboard(32 * 72, 20 * 72);
}
}
function resizeAllArtboards(w, h) {
for (var i = 0; i < ABs.length; i++) {
app.selection = null;
ABs.setActiveArtboardIndex(i);
var idx = docRef.artboards.getActiveArtboardIndex();
var AB = docRef.artboards[idx];
var ABR = AB.artboardRect;
var xC = ABR[0]+((ABR[2]-ABR[0])/2);
var yC = ABR[1]+((ABR[3]-ABR[1])/2);
AB.artboardRect = [xC-w/2, yC+h/2, xC+w/2, yC-h/2];
}
}
function resizeArtboard(w, h) {
var idx = docRef.artboards.getActiveArtboardIndex();
var AB = docRef.artboards[idx];
var ABR = AB.artboardRect;
var xC = ABR[0]+((ABR[2]-ABR[0])/2);
var yC = ABR[1]+((ABR[3]-ABR[1])/2);
AB.artboardRect = [xC-w/2, yC+h/2, xC+w/2, yC-h/2];
}
Copy link to clipboard
Copied
Thank you for the effort. Appreciated