forked from zlovatt/zl_Scriptlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Toggle Layer Expressions.jsx
51 lines (41 loc) · 1.19 KB
/
Toggle Layer Expressions.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
/**
* Disables all enabled expressions on selected layers
* & enables all disabled expressions
*
* @author Zack Lovatt <[email protected]>
* @version 0.1.0
*/
(function toggleLayerExpressions () {
/**
* Recursively loops through all properties and toggles found expressions
*
* @param {PropertyGroup} propertyGroup Property group to loop through
*/
function recursiveToggleExpressions(propertyGroup) {
for (var ii = 1; ii <= propertyGroup.numProperties; ii++) {
var property = propertyGroup.property(ii);
if (!property.isModified) {
continue;
}
if (property instanceof PropertyGroup) {
recursiveToggleExpressions(property);
continue;
}
if (!property.canSetExpression) {
continue;
}
property.expressionEnabled = !property.expressionEnabled;
}
}
app.beginUndoGroup("Toggle Selected Layer Expressions");
var comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
alert("Open a comp!");
return;
}
for (var ii = 0; ii < comp.selectedLayers.length; ii++) {
var layer = comp.selectedLayers[ii];
recursiveToggleExpressions(layer);
}
app.endUndoGroup();
})();