使用 Extendscript 在 After Effects CC 中编写实时表达式?

Write Live expressions in after effects cc using Extendscript?

我正在尝试使用 Extendscript 为 After Effects CC 编写脚本。我想知道是否可以将实时表达式添加到层属性,如 thisComp.layer("Layer 1").transform.position 等等。

希望有可能。

提前致谢:)

这应该适合你。

var expString = "thisComp.layer(\"My-Layer\").transform.position";
var prop = app.project.item(index).layer(index).transform.position;
if(prop.canSetExpression === true){
    prop.expression  = expString;
}

用您的图层 index 和项目 index 替换 index。如果您在表达式中使用字符串,例如

thisComp.layer(\"My-Layer\").transform.position  

你需要正确地转义它们。不要在表达式中使用单引号。例如'My-Layer'。这就产生了新的问题。

看看 After-Effects-CS6-Scripting-Guide.pdf