-
Notifications
You must be signed in to change notification settings - Fork 11
/
Artboard Labels.jsx
56 lines (43 loc) · 1.34 KB
/
Artboard Labels.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
/**
* ArtboardLabelsError object
* @param message
* @param stack
* @constructor
*/
var ArtboardLabelsError = function(message, stack) {
this.message = message || 'Unknown ArtboardLabelsError';
this.stack = stack || null;
}
ArtboardLabelsError.prototype = Error.prototype;
/**
* Create artboard labels.
* @constructor
*/
var ArtboardLabels = function() {
if ( ! app.activeDocument) {
alert(new ArtboardLabelsError("There are no open documents", $.stack));
}
else {
var doc,
artboard,
artboards,
theLabel;
doc = app.activeDocument;
artboards = doc.artboards;
theLayer = doc.layers.add();
theLayer.name = '__LABELS';
doc.activeLayer = theLayer;
for (var i = 0; i < app.activeDocument.artboards.length; i++) {
doc.artboards.setActiveArtboardIndex(i);
artboard = artboards[i];
theLabel = doc.textFrames.add();
theLabel.contents = artboard.name;
theLabel.textRange.characterAttributes.size = 8;
theLabel.position = [
artboard.artboardRect[0],
artboard.artboardRect[1] - (artboard.artboardRect[1] - (theLabel.height - 2))
];
}
}
}
new ArtboardLabels();