ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change layer visibility via Essential Graphics

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matthias Schwarz
Change layer visibility via Essential Graphics
on Nov 6, 2017 at 1:35:57 pm

Hello,

this is my first post here so be kind if I do a mistake. I´m planning to dive deeper into expression controlled Essential
Graphics-Template for Premiere CC. Recently I found a very interesting tutoria with a cool feature: choose a graphic by changing a slider value in the essential graphics panel.
you can see it at minute 6:02, here is the link:






Can anyone explain how this works? I mean, I understand how the slider-expression itself works. But I don´t understand what changes the graphic layers "behind the scenes." I read a post where Dan Ebbert said you can´t control a layers visibility via expressions. What did this guy exactly?

Yours, Matthias


Return to posts index

Kevin Camp
Re: Change layer visibility via Essential Graphics
on Nov 6, 2017 at 8:08:55 pm

you can't use an expression to control whether a layer is active or not (by clicking the eyeball icon for a layer to show/hide it), but you can control visibility via the opacity property.

so you can link a layer's opacity to a slider, then set the opacity to 100 if the corresponding number is set by the slider or 0 if it is not. Something like this:
ctrl = thisComp.layer("control").effect("Slider Control")("Slider");
if ( Math.floor( ctrl ) == 1 ) 100 else 0;


Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Matthias Schwarz
Re: Change layer visibility via Essential Graphics
on Nov 6, 2017 at 10:11:54 pm

Hi,

thanks for the idea. I tried to control a couple of layers and it worked! Fine!

I made a null object and put this expression into a slider control:

Math.floor(clamp(value,2,8));

An on every layer which is controlled by the slider I put this expression to the opacity:

if (thisComp.layer("Controller").effect("Slider")("Schieberegler") == thisLayer.index) 100 else 0;

But now I think about the following: what if I have not only eight layers, but more. Is there a way to find it out by expression(or set the maximum number automatically)?

Like this: Math.floor(clamp(value,2,MaxValue));

I read something about try/catch, does this work or is there another way to achieve this?

Yours, Matthias


Return to posts index


Kevin Camp
Re: Change layer visibility via Essential Graphics
on Nov 7, 2017 at 12:01:09 am

thisComp.numLayers will return the number of layers in the comp.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Matthias Schwarz
Re: Change layer visibility via Essential Graphics
on Nov 8, 2017 at 1:38:30 pm

Wow, that works fine!

I´ll start to learn now all the different commands, it´s very exciting. But one last question about this particular case.
When I put all the pictures in a pre-comp, for the sake of usability(e.g. put more/other pictures inside)-is there a way(I guess so) to let the code

if (thisComp.layer("Controller").effect("Slider")("Schieberegler") == thisLayer.index) 100 else 0;

work "global" in the precomp without the need to copy this expression to all the opacity-properties in the pre-comp?
It should work if there is a way to give it a name, I guess, e.g. "pre-comp.layer" instead of "thisComp.layer". Does this work? I´ve learned Basic and TurboPascal 20 years ago but there are only a few similarities between JavaScript and these "old school" languages. So I try to understand, but every hint like yours here are so precious for me...

Yours, Matthias


Return to posts index

Kevin Camp
Re: Change layer visibility via Essential Graphics
on Nov 8, 2017 at 6:25:16 pm

you'll have to have the expression on each layer that you want to be controlled by the slider. however there is an easy way to do that.

select a layer that has the expression and type 't' on the keyboard to reveal the opacity property. right-click the opacity property and choose 'copy expression only'.

then select all the layers that you want to use that expression and paste. now all those layers will have the same expression, and since your expression is referencing each layer's unique index number, you should be good to go.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index


Matthias Schwarz
Re: Change layer visibility via Essential Graphics
on Nov 8, 2017 at 11:57:16 pm

That´s a good way to safe time! So that´s enough knowledge for the moment. I thank you so much for all the time you spent on helping me! All thumbs up!

Yours, Matthias


Return to posts index

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