Can I check if a layer has an effect?

Moderators: Disciple, zlovatt

Post Reply
thehardme
Posts: 9
Joined: September 21st, 2005, 3:47 am

August 23rd, 2011, 9:27 am

Hi to all!

I am tweaking Ebberts' collission detector for a project. There are going to be a lot of layers in the comp, and some of them will work as obstacles for a collision. I want to make some of these layers obstacles, and one object to collide should detect them. So the ideal would be

if (L.effect("IsObject")(Checkbox))

to check every layer in every frame before going to the collision check. But if a layer doesn't have an effect called IsObject, the expression won't work. Is there a way to detect if a layer has an effect with particular name so I don't have to create this effect on every layer?

Regards
Dan Ebberts
Posts: 319
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

August 23rd, 2011, 11:31 am

Here's an example that should count the layers with the checkbox:

Code: Select all

n = 0;
for (i = 1; i <= thisComp.numLayers; i++){
  if (i == index) continue; // skip myself
  try{
    thisComp.layer(i).effect("isObject")("Checkbox");
  }catch (e){
    continue;
  }
  n++;
}
n
Dan
thehardme
Posts: 9
Joined: September 21st, 2005, 3:47 am

August 23rd, 2011, 1:08 pm

Thanks a lot, Dan, it's now working beatifully.
Post Reply