-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathResize All Artboards.jsx
More file actions
59 lines (48 loc) · 1.57 KB
/
Copy pathResize All Artboards.jsx
File metadata and controls
59 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Based on the script resizeArtboards_CS4andUp.jsx by Carlos Canto 11/4/12
*/
#target Illustrator
var OPTIONS = {
size : 32,
width : 32,
height : 32
};
if (app.documents.length == 0) {
alert("there are no open documents");
}
else {
var idoc = app.activeDocument;
var title = "Resize All Artboards";
OPTIONS.size = Window.prompt ("Enter New Artboard size in pixels as WxH ( Example: 250x300 )", 32, title);
if (OPTIONS.size.indexOf('x') != -1) {
var bits = OPTIONS.size.split('x');
OPTIONS.width = parseInt(bits[0]);
OPTIONS.height = parseInt(bits[1]);
}
else {
OPTIONS.width = OPTIONS.size;
OPTIONS.height = OPTIONS.size;
}
try {
var width = OPTIONS.width;
var height = OPTIONS.height;
for (i=0; i<idoc.artboards.length; i++) {
var abBounds = idoc.artboards[i].artboardRect; // left, top, right, bottom
var ableft = abBounds[0];
var abtop = abBounds[1];
var abwidth = abBounds[2] - ableft;
var abheight = abtop- abBounds[3];
var abctrx = abwidth / 2 + ableft;
var abctry = abtop - abheight / 2;
var ableft = abctrx - width / 2;
var abtop = abctry + height / 2;
var abright = abctrx + width / 2;
var abbottom = abctry - height / 2;
idoc.artboards[i].artboardRect = [ableft, abtop, abright, abbottom];
}
}
catch(e) {
alert(e.message);
/** Exist gracfully for now */
}
}