-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISO_RandomizeSeeds.jsx
More file actions
79 lines (63 loc) · 2.22 KB
/
Copy pathISO_RandomizeSeeds.jsx
File metadata and controls
79 lines (63 loc) · 2.22 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
70
71
72
73
74
75
76
77
78
79
// ISO_RandomizeSeeds.jsx
// Artist: https://www.jasonfletcher.info/
// Code generated by ChatGPT-4o
// Date: April 16, 2025
// Description: This After Effects script will look at the selected comps in the Project window and then randomize the seed value for all wiggle expressions (in all layers).
(function () {
app.beginUndoGroup("Randomize Wiggle Seeds");
var selectedItems = app.project.selection;
var modifiedCount = 0;
var compsAffected = 0;
function isComp(item) {
return item instanceof CompItem;
}
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function updateSeedInExpression(expr, newSeed) {
return expr.replace(/seedRandom\(\s*\d+\s*,\s*(true|false)\s*\)/, "seedRandom(" + newSeed + ", $1)");
}
function processProperty(prop) {
if (prop.canSetExpression && prop.expressionEnabled && prop.expression) {
if (/seedRandom\(/.test(prop.expression) && /wiggle\(/.test(prop.expression)) {
var newSeed = randomInt(1, 10000);
var newExpr = updateSeedInExpression(prop.expression, newSeed);
if (newExpr !== prop.expression) {
prop.expression = newExpr;
modifiedCount++;
}
}
}
}
function processProperties(group) {
for (var i = 1; i <= group.numProperties; i++) {
var prop = group.property(i);
if (prop.numProperties > 0) {
processProperties(prop);
} else {
processProperty(prop);
}
}
}
function processComp(comp) {
var before = modifiedCount;
for (var j = 1; j <= comp.numLayers; j++) {
var layer = comp.layer(j);
processProperties(layer);
}
if (modifiedCount > before) {
compsAffected++;
}
}
for (var i = 0; i < selectedItems.length; i++) {
var comp = selectedItems[i];
if (isComp(comp)) {
processComp(comp);
}
}
app.endUndoGroup();
alert(
"Expressions updated: " + modifiedCount + "\n" +
"Comps affected: " + compsAffected
);
})();