-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObjectArea.jsx
65 lines (53 loc) · 1.83 KB
/
ObjectArea.jsx
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
60
61
62
63
64
65
// ObjectArea.jsx
// Adobe Illustrator CSx script
// gives you the area size of an object
// test env: Adobe Illustrator CS6 oon Win x64
// 2016-02-03
// Lucas Becker
// https://github.com/runxel
// This script is distributed under the MIT License.
// -------------------------------------------------
main();
function main(){
if (documents.length < 1) return;
var selObjects = app.activeDocument.selection;
var selObjectsNum = selObjects.length;
if(selObjectsNum < 1){
alert("You must select one path before launching this script.")
return;
}
if(selObjectsNum > 1){
alert("Please select only one path at a time.")
return;
}
// show a dialog
var win = new Window("dialog", "Object Area");
win.orientation = "column";
win.alignChildren = "fill";
win.radioPanel = win.add("panel", [15, 76, 215, 122], "unit");
win.radioPanel.orientation = "row";
win.radioPanel.cm = win.radioPanel.add("radiobutton", undefined, "cm²");
win.radioPanel.mm = win.radioPanel.add("radiobutton", undefined, "mm²");
win.radioPanel.inch = win.radioPanel.add("radiobutton", undefined, "inches²");
win.radioPanel.cm.value = true;
win.output = win.add("panel", [15, 15, 240, 61], "area size");
win.output.orientation = "row";
win.output.txtBox = win.output.add("edittext", [175, 14, 370, 34], areaSize(0.01));
win.radioPanel.cm.onClick = function() {
win.output.txtBox.text = areaSize(0.01);
}
win.radioPanel.mm.onClick = function() {
win.output.txtBox.text = areaSize(1);
}
win.radioPanel.inch.onClick = function() {
win.output.txtBox.text = areaSize(0.00155);
}
win.show();
}
function areaSize(mult) {
var size = 0;
// standard value is in pixels
size = parseFloat(Math.abs(app.activeDocument.selection[0].area/8.03521617));
size = Math.abs(size * mult).toFixed(3)
return size;
}