Copy link to clipboard
Copied
In extendscript, how can I check if a layer has a specific effect applied to it? For example, suppose I want to check if a given layer has the "motion tile" effect applied to it. Essentially, this is the pseudocode of what I want:
var layer_number = 1;
if (app.project.item(1).layer(layer_number) has motion tile applied)
{
alert("It does!");
}
else
{
add motion tile effect to app.project.item(1).layer(layer_number);
}
Can somebody please help me translate this pseudocode into real code that extendscript will recognize for After Effects? Thanks.
Something like this:
var myLayer = app.project.activeItem.layer(1);
var hasEffect = false;
for (var i = 1; i <= myLayer.property("Effects").numProperties; i++){
if (myLayer.property("Effects").property(i).matchName == "ADBE Tile"){
alert ("It does!");
hasEffect = true;
break;
}
}
if (! hasEffect){
myLayer.property("Effects").addProperty("ADBE Tile");
}
Dan
Copy link to clipboard
Copied
Something like this:
var myLayer = app.project.activeItem.layer(1);
var hasEffect = false;
for (var i = 1; i <= myLayer.property("Effects").numProperties; i++){
if (myLayer.property("Effects").property(i).matchName == "ADBE Tile"){
alert ("It does!");
hasEffect = true;
break;
}
}
if (! hasEffect){
myLayer.property("Effects").addProperty("ADBE Tile");
}
Dan
Copy link to clipboard
Copied
Perfect, thank you very much!