forked from zlovatt/zl_Scriptlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelect Alternating Keyframes.jsx
55 lines (42 loc) · 1.23 KB
/
Select Alternating Keyframes.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
/**
* Selects every other keyframe on a given property.
*
* Hold SHIFT to offset start counter (select evens, not odds)
*
* @author Zack Lovatt <[email protected]>
* @version 0.1.0
*/
(function selectAlternatingKeyframes() {
var offset = ScriptUI.environment.keyboardState.shiftKey ? 1 : 0;
var comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
alert("Please select a composition!", "Select Alternating Keyframes");
return;
}
var props = comp.selectedProperties;
if (props.length === 0) {
alert("Please select some properties!", "Select Alternating Keyframes");
return;
}
app.beginUndoGroup("Select Alternating Keyframes");
for (var ii = 0, il = props.length; ii < il; ii++) {
var prop = props[ii];
if (!prop.canSetExpression) {
continue;
}
var jj, jl;
// Deselect all keyframes
for (jj = 1, jl = prop.numKeys; jj <= jl; jj++) {
prop.setSelectedAtKey(jj, false);
}
// Select alternating pattern
for (jj = 0, jl = prop.numKeys; jj < jl; jj = jj + 2) {
var keyIndex = jj + 1 + offset;
if (keyIndex > prop.numKeys) {
continue;
}
prop.setSelectedAtKey(keyIndex, true);
}
}
app.endUndoGroup();
})();