ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

using a layer's visibility in an if/then expression on another layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
mel ruiz
using a layer's visibility in an if/then expression on another layer
on Jan 16, 2018 at 8:17:12 pm

What I'm trying to do is include an if statement in a position expression that is looking up the visibility of a layer. So that if a layer is hidden (with the "eye" turned off) then the position will be different than if it is not hidden/turned on. I can't use opacity, as people will be either leaving a layer on or hiding it and I need my expression to account for that choice.

I can't seem to find out how to call out a layer's visibility in that way...maybe it's not possible? Anyone know? thanks!

AE 2017


Return to posts index

Kevin Camp
Re: using a layer's visibility in an if/then expression on another layer
on Jan 16, 2018 at 8:50:19 pm

the attribute you are looking for is 'active'.

try this:

target = thisComp.layer("My Layer") ;
p1 = [ 100, 100 ] ;
p2 = [100, 400 ] ;
if ( target.active == true ) p1 else p2 ;

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Dan Ebberts
Re: using a layer's visibility in an if/then expression on another layer
on Jan 16, 2018 at 8:50:36 pm

Here's a position expression that will move the layer 100 pixels to the right if Layer 1's eyeball is on:


if (thisComp.layer("Layer 1").active)
value + [100,0]
else
value



Dan



Return to posts index


mel ruiz
Re: using a layer's visibility in an if/then expression on another layer
on Jan 17, 2018 at 1:16:40 am

That is EXACTLY what I wanted. Thank you both!


Return to posts index

David Cabestany
Re: using a layer's visibility in an if/then expression on another layer
on Feb 25, 2020 at 3:54:23 pm

Any chance to do this with three different target layers?
So if the 1st one is active the position is A, is the 2nd is active the position is B and if the 3rd is active the position is C?


Return to posts index

Dan Ebberts
Re: using a layer's visibility in an if/then expression on another layer
on Feb 25, 2020 at 4:55:44 pm

Could be like this (depending on which one you want to have precedence.


posA = [100,100];
posB = [200,200];
posC = [300,300];

if (thisComp.layer("Layer 1").active)
posA
else if (thisComp.layer("Layer 2").active)
posB
else if (thisComp.layer("Layer 3").active)
posC
else
value




Return to posts index


Alex Printz
Re: using a layer's visibility in an if/then expression on another layer
on Feb 25, 2020 at 5:13:22 pm

Dan I thought else If statements didn't work in After Effects? Are they available again with the new Javascript engine?

Alex Printz
Mograph Designer


Return to posts index

Dan Ebberts
Re: using a layer's visibility in an if/then expression on another layer
on Feb 25, 2020 at 5:36:01 pm

As far as I know, they've always worked. There's an issue with single-line if else statements and the new engine, but I think that's it.

Dan



Return to posts index

David Cabestany
Re: using a layer's visibility in an if/then expression on another layer
on Feb 26, 2020 at 12:39:52 am

Yes, I ended up using something very close to it. The variables are not at the beginning of the expression.

I thought it would be more complex than it actually is.

Thanks Dan.


Return to posts index

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