Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression that checks if Effect on another layer is present

  • Expression that checks if Effect on another layer is present

    Posted by Daniel Hashimoto on March 6, 2019 at 8:53 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\”

    Daniel Hashimoto replied 7 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Oleg Pirogov

    March 7, 2019 at 12:28 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];
    }

  • Daniel Hashimoto

    March 7, 2019 at 2:10 pm

    Thank you so much! That’s it!

    – Daniel Hashimoto
    \”Action Movie Dad\”

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy