-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISO_TrackMatteMulti.jsx
More file actions
69 lines (58 loc) · 2.13 KB
/
Copy pathISO_TrackMatteMulti.jsx
File metadata and controls
69 lines (58 loc) · 2.13 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ISO_TrackMatteMulti.jsx
// Artist: https://www.jasonfletcher.info/
// Code generated by ChatGPT-5.5
// Date: July 24, 2026
// Description: This After Effects script will assign a track matte (alpha mode) using the odd-numbered layers to the even-numbered layers in the active composition.
(function () {
app.beginUndoGroup("Set Alpha Track Matte Every Other Layer");
try {
var comp = app.project.activeItem;
if (!(comp instanceof CompItem)) {
alert("Please make an active composition the frontmost Timeline panel and run the script again.");
return;
}
var processedCount = 0;
var unchangedCount = 0;
var skippedCount = 0;
var skippedLayers = [];
var i;
for (i = 2; i <= comp.numLayers; i += 2) {
var layer = comp.layer(i);
var matteLayer = comp.layer(i - 1);
if (layer === null || matteLayer === null) {
skippedCount++;
skippedLayers.push(i);
continue;
}
// Leave existing track mattes unchanged.
if (layer.hasTrackMatte) {
unchangedCount++;
continue;
}
try {
layer.setTrackMatte(matteLayer, TrackMatteType.ALPHA);
processedCount++;
} catch (err) {
skippedCount++;
skippedLayers.push(i);
}
}
var message = "";
message += "Alpha Track Matte assignment complete.\n\n";
message += "Composition: " + comp.name + "\n";
message += "Track Matte Type: Alpha Matte\n\n";
message += "Layers updated: " + processedCount + "\n";
message += "Layers already using a track matte: " + unchangedCount + "\n";
message += "Layers skipped: " + skippedCount;
if (skippedLayers.length > 0) {
message += "\n\nSkipped layer numbers:\n" + skippedLayers.join(", ");
}
alert(message);
}
catch (err) {
alert("An error occurred:\n\n" + err.toString());
}
finally {
app.endUndoGroup();
}
})();