-
Notifications
You must be signed in to change notification settings - Fork 22
/
Toggle All Layer Effects.jsx
51 lines (42 loc) · 1.13 KB
/
Toggle All Layer Effects.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
/**
* Toggles on/off all effects on layers in the project
*
* @author Zack Lovatt <[email protected]>
* @version 0.1.0
*/
(function toggleAllLayerEffects() {
var effectsOn = false;
if (confirm("Turn effects ON ('Yes') or OFF ('No')?")) {
effectsOn = true;
}
app.beginUndoGroup("Toggle All Layer Effects");
try {
var items = app.project.items;
for (var ii = 1, il = items.length; ii <= il; ii++) {
var item = items[ii];
if (!(item instanceof CompItem)) {
continue;
}
toggleCompLayerEffects(item, effectsOn);
}
} catch (e) {
alert(e, "Toggle All Layer Effects");
} finally {
app.endUndoGroup();
}
/**
* Toggles layer effects on/off for all layers in given comp
*
* @param {CompItem} comp Comp to toggle effects in
* @param {boolean} effectsOn Whether to turn the effects on or off
*/
function toggleCompLayerEffects(comp, effectsOn) {
for (var ii = 1, il = comp.numLayers; ii <= il; ii++) {
var layer = comp.layer(ii);
if (!(layer instanceof AVLayer)) {
continue;
}
layer.effectsActive = effectsOn;
}
}
})();