ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression that checks if Effect on another layer is present

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Daniel Hashimoto
Expression that checks if Effect on another layer is present
on Mar 6, 2019 at 8:53:46 pm

I'm trying to create an effect that sets the position of a lens flare to the location of someone's pupil if you've run the Detailed Face Tracker on a layer below - however, I'd like the expression to check whether the Face Tracker effect exists first, and if not, give a different default result.

So I think I need an if/else to check whether that layer has the effect?

I was thinking something like this where the this expression is on the location of a lens flare on a Black Solid, above a layer "SOURCE". Desired output is the Right Pupil location (which works on its own) if the Source layer has the "detailed Face Tracker" effect applied - but will return [0,0] if no effect is present.

Thank you for your help!

if(thisComp.layer("SOURCE").effect("Face Track Points")("Right Pupil"))==null){[0,0]}else{thisComp.layer("SOURCE").effect("Face Track Points")("Right Pupil")}


- Daniel Hashimoto
"Action Movie Dad"


Return to posts index

Oleg Pirogov
Re: Expression that checks if Effect on another layer is present
on Mar 7, 2019 at 12:28:10 am

Since a reference to non-existent property raises an exception, you can use try-catch:

var someVar;
try{
someVar =thisComp.layer("SOURCE").effect("Face Track Points")("Right Pupil");
}
catch(err){
someVar=[0,0];
}


Return to posts index

Daniel Hashimoto
Re: Expression that checks if Effect on another layer is present
on Mar 7, 2019 at 2:10:09 pm

Thank you so much! That's it!

- Daniel Hashimoto
"Action Movie Dad"


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]