When working with Adobe After Effects, you may need to identify property names for specific elements within a layer. This can be a crucial step in scripting and automation. The following script provides a way to recursively walk through the property chain of selected layer(s) and outputs the match names and display names directly to the JavaScript console. Here’s how you can use it effectively.
(function() { // wrap entire script in an anonymous function to create a private scope within AE's global namespace
main();
function dumpPropTree(rootObj, nestingLevel) {
var countProps = rootObj.numProperties;
for (var propIndex=1; propIndex <= countProps; propIndex++) {
var prop = rootObj.property(propIndex);
$.writeln(Array(nestingLevel*4).join(" ") + "[" + nestingLevel + "-" + propIndex + "] " + "matchName: \"" + prop.matchName + "\", name: \"" + prop.name + "\"");
if (prop.numProperties > 0)
dumpPropTree(prop, nestingLevel+1);
}
}
function main() {
var activeComp = app.project.activeItem;
if (activeComp == null) {
alert("Error: No active composition");
return;
}
var countSelectedLayers = activeComp.selectedLayers.length;
if (countSelectedLayers == 0) {
alert("Error: No selected layer(s)");
return;
}
for (selectedLayerIndex=0; selectedLayerIndex < countSelectedLayers; selectedLayerIndex++) {
var layer = activeComp.selectedLayers[selectedLayerIndex];
$.writeln("***************** [ Layer: \"" + layer.name + "\" ] *****************");
dumpPropTree(layer, 0);
}
}
})(); // end of anonymous function that encapsulates entire script
Purpose of the Script
This script is useful for exploring the structure of a layer and understanding its properties. It provides a detailed breakdown of each property, helping you identify specific elements for scripting within Adobe After Effects.
How to Use the Script
- Preparation:
- Select the layer(s) in your After Effects project for which you’d like to explore properties.
- Open Adobe ExtendScript CC debugger.
- Execution:
- Paste the script into the debugger and run it.
- Output:
- The script will output the hierarchy of properties, including their match names and display names, to the JavaScript console.
Sample Output
When executed, the script produces an output in the JavaScript console resembling the following:
[0-1] matchName: "ADBE Transform Group", name: "Transform"
[1-1] matchName: "ADBE Position", name: "Position"
[1-2] matchName: "ADBE Anchor Point", name: "Anchor Point"
[1-3] matchName: "ADBE Scale", name: "Scale"
This structure shows each property in the layer, along with its match name and display name. The nesting level indicates the property hierarchy.
Key Benefits
- Provides detailed insight into the property structure of layers.
- Helps in identifying properties for scripting and automation.
- Simplifies debugging and development workflows within Adobe After Effects.