-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEF_ExportActiveCompExpressionsToFile.jsx
73 lines (57 loc) · 2.58 KB
/
EF_ExportActiveCompExpressionsToFile.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**========================================================================
* ? EF_ExportActiveCompExpressionsToFile.jsx
* @author Eveline Falcão (https://evelinefalcao.com)
* @email [email protected]
* @version 1.0.0
* @createdFor Adobe After Effects CC 2024 (Version 24.1.0 Build 78)
* @description Exports the expressions of the active comp to a .jsx file.
*========================================================================**/
(function exportActiveCompExpressionsToFile() {
app.beginUndoGroup("Export Active Comp Expressions");
var project = app.project;
var projectPath = project.file;
var projectName = projectPath.toString();
var comp = project.activeItem;
var layers = comp.layers;
var docHeader = "/*\n\tProject: " + projectName + "\n\tComposition: " + comp.name + "\n*/";
var expressions = [docHeader];
function processProperty(property, curLayerName, curLayerIndex) {
// Pass a layer or a prop
if (property.propertyType == PropertyType.PROPERTY) { // Check if value is a single property and do something
if (property.expressionEnabled) {
var string = "// Layer " + curLayerIndex + ": \"" + curLayerName + "\" - " + property.name + "\n";
var exp = property.expression.replace(/[\r\n]+/g, "\n").trim();
var expression = string + exp;
expressions.push(expression);
}
} else {
for (var i = 1; i <= property.numProperties; i++) {
processProperty(property.property(i), curLayerName, curLayerIndex);
}
}
}
for (var layer = 1; layer <= layers.length; layer++) {
var currentLayer = layers[layer];
var curLayerName = currentLayer.name;
var curLayerIndex = currentLayer.index;
// alert(curLayerName);
processProperty(currentLayer, curLayerName, curLayerIndex);
}
// Check if project is saved
if (projectPath != null) {
var filePath = projectPath.toString().replace(".aep", "");
} else {
alert("Save your project to continue.")
}
// Separates each item with three line breaks
var expressionsString = expressions.join("\n\n\n\n");
// Prompt to save the file
var file = new File(filePath + "_" + comp.name + "_Expressions.jsx").saveDlg("Select the file destination.", "*.jsx");
// Write the file
if (file != null) {
file.open("w");
file.write(expressionsString);
file.close();
}
app.endUndoGroup();
})();