-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathToggle Motion Blur for Selected Layers.jsx
More file actions
50 lines (44 loc) · 1.58 KB
/
Copy pathToggle Motion Blur for Selected Layers.jsx
File metadata and controls
50 lines (44 loc) · 1.58 KB
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
/*
* Toggle Motion Blur for Selected Layers
*
* Quickly toggles the motion blur switch for all selected layers in the
* active composition. If any selected layer has motion blur disabled, the
* script enables motion blur for every selected layer. If all selected
* layers already have motion blur enabled, the script disables the switch
* for all of them. Layers that do not support motion blur are skipped.
*/
(function toggleMotionBlurForSelectedLayers() {
if (!app || !app.project) {
alert("No active project found. Please open a project first.");
return;
}
app.beginUndoGroup("Toggle Motion Blur for Selected Layers");
var activeItem = app.project.activeItem;
if (!(activeItem instanceof CompItem)) {
alert("Please select a composition and try again.");
app.endUndoGroup();
return;
}
var selectedLayers = activeItem.selectedLayers;
if (!selectedLayers || selectedLayers.length === 0) {
alert("Select at least one layer to toggle motion blur.");
app.endUndoGroup();
return;
}
var shouldEnable = false;
for (var i = 0; i < selectedLayers.length; i += 1) {
var layer = selectedLayers[i];
if (layer instanceof AVLayer && !layer.motionBlur) {
shouldEnable = true;
break;
}
}
for (var j = 0; j < selectedLayers.length; j += 1) {
var currentLayer = selectedLayers[j];
if (!(currentLayer instanceof AVLayer)) {
continue;
}
currentLayer.motionBlur = shouldEnable;
}
app.endUndoGroup();
})();