-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
58 lines (42 loc) · 1.07 KB
/
test.js
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
(function() {
try {
// @include '../LST.js'
var layer = getTargetLayer('TARGET');
var toComp = LST.toComp(layer);
var toWorld = LST.toWorld(layer);
alert([
'LST results:',
'toComp():\n' + toComp.join('\n'),
'---',
'toWorld():\n' + toWorld.join('\n')
].join('\n'));
} catch (error) {
handleError(error);
}
///
function getTargetLayer(layerName) {
var composition, layer;
composition = getActiveComposition();
layer = composition.layer(layerName);
if (!layer) {
throw 'Could not find ' + layerName + ' layer';
}
return layer;
}
function getActiveComposition() {
var composition = app.project.activeItem;
if (!composition || !(composition instanceof CompItem)) {
throw 'Please select composition first';
}
return composition;
}
function handleError(error) {
var message = error.toString();
if (error instanceof Error) {
message += '\nScript File: ' + File(error.fileName).displayName +
'\nFunction: ' + arguments.callee.name +
'\nError on Line: ' + error.line.toString();
}
alert(message);
}
})();