forked from zlovatt/zl_Scriptlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Add Trim Paths.jsx
55 lines (41 loc) · 1.26 KB
/
Add Trim Paths.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
/**
* Adds Trim Paths to selected shape layers, including a keyframe to start and one to end the animation.
*
* Hold SHIFT when running the script to _not_ add keyframes.
*
* @author Zack Lovatt <zack@lova.tt>
* @version 1.3.1
*/
(function addTrimPaths() {
var addKeys = !ScriptUI.environment.keyboardState.shiftKey;
var comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
alert("Please select a composition!");
return;
}
var layers = comp.selectedLayers;
if (layers.length === 0) {
alert("Please select some layers!");
return;
}
app.beginUndoGroup("Add Trim Paths");
for (var ii = 0, il = layers.length; ii < il; ii++) {
var layer = layers[ii];
if (layer.matchName !== "ADBE Vector Layer") {
continue;
}
var contents = layer.property("ADBE Root Vectors Group");
if (!contents.canAddProperty("ADBE Vector Filter - Trim")) {
continue;
}
var trimProp = contents.addProperty("ADBE Vector Filter - Trim");
if (!addKeys) {
continue;
}
var trimEnd = trimProp.property("ADBE Vector Trim End");
var trimTimes = [layer.inPoint, layer.inPoint + 1];
var trimValues = [0, 100];
trimEnd.setValuesAtTimes(trimTimes, trimValues);
}
app.endUndoGroup();
})();