Activity › Forums › Adobe After Effects Expressions › using a layer’s visibility in an if/then expression on another layer
-
using a layer’s visibility in an if/then expression on another layer
Posted by Mel Ruiz on January 16, 2018 at 8:17 pmWhat 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
Elizabeth Starr replied 6 years, 2 months ago 6 Members · 13 Replies -
13 Replies
-
Kevin Camp
January 16, 2018 at 8:50 pmthe 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 -
Dan Ebberts
January 16, 2018 at 8:50 pmHere’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
-
David Cabestany
February 25, 2020 at 3:54 pmAny 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? -
Dan Ebberts
February 25, 2020 at 4:55 pmCould 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
-
Alex Printz
February 25, 2020 at 5:13 pmDan I thought else If statements didn’t work in After Effects? Are they available again with the new Javascript engine?
Alex Printz
Mograph Designer -
Dan Ebberts
February 25, 2020 at 5:36 pmAs 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
-
David Cabestany
February 26, 2020 at 12:39 amYes, 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.
-
Elizabeth Starr
May 12, 2020 at 8:49 pmHow would I write an expression to tell a text layer move 56 pixels to the left or right depending on whether or not a checkbox is checked on other layers? If any one of the checkboxes are checked, the text layer needs to move 56 pixels to the right to make room for a logo. If all of the checkboxes are off, then the text layer needs to move to the left to make up for the space that the absent logo leaves behind. I have 6 layers with a logo on each layer. The end user (this will become a MOGRT file) will have the option of choosing whether they want a logo next to the text line or no logo.
-
David Cabestany
May 12, 2020 at 9:04 pmSomething like this maybe?
I have no idea about the MOGRT format, sorry.Someone smarter, like Dan Ebberts can probably write it cleaner.
lay1 = thisComp.layer("1").effect("a")("Checkbox");
lay2 = thisComp.layer("2").effect("b")("Checkbox");
lay3= thisComp.layer("3").effect("c")("Checkbox");
lay4= thisComp.layer("4").effect("x")("Checkbox");
lay5= thisComp.layer("5").effect("y")("Checkbox");
lay6= thisComp.layer("6").effect("z")("Checkbox");
y=transform.position[1];
if
(lay1==1 || lay2==1 || lay3==1|| lay4==1|| lay5==1|| lay6==1)
{
x=(your value with the 56 pixels added to the left or right, for example 500);
}
;
else
x= 556;
[x,y];
Reply to this Discussion! Login or Sign Up