Activity › Forums › Adobe After Effects Expressions › Check for a specific layer name
-
Check for a specific layer name
Posted by Weeeeeeeee on February 4, 2007 at 9:30 pmI’m trying to find a way to make my expression check for the existece of a layer with a specific name, in order to avoid getting an error alert when the layer is mentioned later on in the expression.
Is this possible?
Dan Ebberts replied 19 years, 7 months ago 3 Members · 5 Replies -
5 Replies
-
Relupene
February 5, 2007 at 5:20 pmfindName = “Name of layer you need to find”;
for (i =1; i <=thisComp.numLayers; ++i) { if (thisComp.layer(i).name.indexOf(findName) != -1) { // do what you need for this; } } -
Dan Ebberts
February 5, 2007 at 10:54 pmA JavaScript try/catch construct should do the trick:
try{
L = thisComp.layer(“X”);
exists = true;
}catch (err){
exists = false;
}if (exists){
// add the stuff to do when the layer exists
}else{
// add the stuff to do when the layer doesn’t exist
}Dan
-
Dan Ebberts
February 6, 2007 at 1:07 amThis is probably a better way:
if (myComp.layer(“EDL”) == null){
// stuff to do if layer doesn’t exist
}else{
// stuff to do if layer does exist
}
Dan
-
Weeeeeeeee
February 6, 2007 at 10:48 pmThanks! Simple and good!
Do you also know how to check which property the expression is applied to?
I need to make a universal expression that automaticly knows how to react just by telling which property it’s applied to. -
Dan Ebberts
February 7, 2007 at 7:15 pmNo, unfortunately there is no thisProperty.name attribute.
Dan
Reply to this Discussion! Login or Sign Up