The Expressions Thread

felt_tips just locked my thread so i’m here, here is my problem : i’m making an ident template ( https://www.youtube.com/watch?v=sYXpYzC4ehU&list=UU26xFDgmcDXT-vY7rvTpv6w ) and i would like to add checkboxs for the buyer so he can enable or disable an element with just a click. Does anyone know how to do it ? Thanks

Motion Max answered me :
for example if you are using checkbox control for opacity apply to the checkbox control to some layer for ex Null 01 alt+click on opacity timer it will look like this

if(comp(“comp name”).layer(“layer name”).effect(“Checkbox Control”)(1)==0)0 else 100;

comp(“comp name”).layer(“layer name”).effect(“Checkbox Control”)(1) for this you can pick from while wrting the expresssion on layer

Me : http://i.imgur.com/imnm60d.png As you can see, i’m trying to add an enable/disable effect with check box, The layer is called circle and the check box is called ^ci containned on the layer called Elements color|ON/OFF

Motion Max answered me :
only write this expression
if(comp(“ANIMATION”).layer(“Elements color|ON/OFF”).effect(“ci”)(1)==0)0 else 100;
instead of Checkbox Control you have to write ^ci


Back from work, i’ve tried what he told me to do but this error message poped up http://i.imgur.com/apvxayl.png
thanks guys to help me ;s

MartinLemaire said

felt_tips just locked my thread so i’m here, here is my problem : i’m making an ident template ( https://www.youtube.com/watch?v=sYXpYzC4ehU&list=UU26xFDgmcDXT-vY7rvTpv6w ) and i would like to add checkboxs for the buyer so he can enable or disable an element with just a click. Does anyone know how to do it ? Thanks

Motion Max answered me :
for example if you are using checkbox control for opacity apply to the checkbox control to some layer for ex Null 01 alt+click on opacity timer it will look like this

if(comp(“comp name”).layer(“layer name”).effect(“Checkbox Control”)(1)==0)0 else 100;

comp(“comp name”).layer(“layer name”).effect(“Checkbox Control”)(1) for this you can pick from while wrting the expresssion on layer

Me : http://i.imgur.com/imnm60d.png As you can see, i’m trying to add an enable/disable effect with check box, The layer is called circle and the check box is called ^ci containned on the layer called Elements color|ON/OFF

Motion Max answered me :
only write this expression
if(comp(“ANIMATION”).layer(“Elements color|ON/OFF”).effect(“ci”)(1)==0)0 else 100;
instead of Checkbox Control you have to write ^ci


Back from work, i’ve tried what he told me to do but this error message poped up http://i.imgur.com/apvxayl.png
thanks guys to help me ;s

hi there again you have entered ci instead of ^ci

MotionMAX said
MartinLemaire said

felt_tips just locked my thread so i’m here, here is my problem : i’m making an ident template ( https://www.youtube.com/watch?v=sYXpYzC4ehU&list=UU26xFDgmcDXT-vY7rvTpv6w ) and i would like to add checkboxs for the buyer so he can enable or disable an element with just a click. Does anyone know how to do it ? Thanks

Motion Max answered me :
for example if you are using checkbox control for opacity apply to the checkbox control to some layer for ex Null 01 alt+click on opacity timer it will look like this

if(comp(“comp name”).layer(“layer name”).effect(“Checkbox Control”)(1)==0)0 else 100;

comp(“comp name”).layer(“layer name”).effect(“Checkbox Control”)(1) for this you can pick from while wrting the expresssion on layer

Me : http://i.imgur.com/imnm60d.png As you can see, i’m trying to add an enable/disable effect with check box, The layer is called circle and the check box is called ^ci containned on the layer called Elements color|ON/OFF

Motion Max answered me :
only write this expression
if(comp(“ANIMATION”).layer(“Elements color|ON/OFF”).effect(“ci”)(1)==0)0 else 100;
instead of Checkbox Control you have to write ^ci


Back from work, i’ve tried what he told me to do but this error message poped up http://i.imgur.com/apvxayl.png
thanks guys to help me ;s

hi there again you have entered ci instead of ^ci

http://imgur.com/xQBspqQ I must be so dumb …

Well… YEs i’m so freacking dumb :smiley:
All i had to do was to simply type *100 after the expression
thisComp.layer(“Elements”).effect("^ci")(“Checkbox”)*100
Thank you guys for the help that you gave to me, even if i’ve found by myself.

MartinLemaire said

Well… YEs i’m so freacking dumb :smiley:
All i had to do was to simply type *100 after the expression
thisComp.layer(“Elements”).effect("^ci")(“Checkbox”)*100
Thank you guys for the help that you gave to me, even if i’ve found by myself.

Or you could have used an if / else statement as Motion Max suggested in the beginning. :slight_smile:

if(thisComp.layer("Elements").effect("^ci")(1).value) 100; else 0;

or a ternary… ( condition ? result 1 : result 2 )

tSwitch = thisComp.layer("Elements").effect("^ci")(1).value;
tSwitch ? 100 : 0;

Actually, these two are probably more generally useful than your *100, because they’ll allow for situations where the second value is not 0… for instance…

tSwitch = thisComp.layer("Elements").effect("^ci")(1).value;
tSwitch ? 70 : 20;

Or maybe on a color property…

tSwitch = thisComp.layer("Elements").effect("^ci")(1).value;
tSwitch ? [255, 109 ,73, 255]/255 :[0,0,0,1]/255;

or a 2D position property…

tSwitch = thisComp.layer("Elements").effect("^ci")(1).value;
tSwitch ? [50,199] : [200,45];

Watch out a little with refs to checkbox. It’s a good idea to specifically reference the value, rather than the container object. It’s usually okay, but sometimes you get into trouble if you don’t specifiy explicitly: effect(“the checkbox effect”)(1).value;

You’ll also notice that throughout, I’ve replaced (“Checkbox”) with the property index (1). This is a good habit. It’s shorter to type and universal (i.e. works in all language versions - very useful for templates).

Is there any way to move markers with expressions?

I want to have a marker move based on how long a scene is, is that possible?

GrizzleFX said

Is there any way to move markers with expressions?

I want to have a marker move based on how long a scene is, is that possible?

Only possible with scripting, I’m afraid.

Great idea! :wink:

Ilya_Mozheev said

Great idea! :wink:

All of your 10 posts so far say something like “Great idea”, Ilya. I’m not quite sure what you mean.

It looks for all the world like you’re after a bit of publicity for your portfolio. Could that be the case? If so, it’s a bit of a wrong move. You probably won’t achieve the publicity you’re looking for and you run the risk of getting banned.

Hey, it’s me again, i would like to create a lower third template. Is it possible for the user to simply change the duration of the lower third, i mean it comes in and then the user could choose how much seconds it needs until it goes out, by the way, during the time to “change”, i have a little looping square mooving from left to right. Thanks

MartinLemaire said

Hey, it’s me again, i would like to create a lower third template. Is it possible for the user to simply change the duration of the lower third, i mean it comes in and then the user could choose how much seconds it needs until it goes out, by the way, during the time to “change”, i have a little looping square mooving from left to right. Thanks

Have a look at Layer->Time Remapping

I didn’t get it. Could you explain more please ?

You can use Time Remapping to speed things up or down. Just do what felt_tips said and you will see 2 keyframes pop up under the composition. Then you can adjust the speed of the animation.

Yeah thanks but does anyone know a solution to make it “easy” for the buyer ? How could i add a slider effect that could adjust the speed ?
Thanks for your answers

If you scroll down to the 8th post I think this is what your looking for. Although I haven’t tried it out for my self.

RMdeJong said

If you scroll down to the 8th post I think this is what your looking for. Although I haven’t tried it out for my self.

Yep, this is what you’re looking for, using the layer’s in and out points as the stretch. Doesn’t get much easier for the buyer than that.

therealist said

“How do I link the second keyframe of an animation to a slider? Only the second keyframe. The effect is Trim Paths to a shape layer.”

Hello! I had a same problem like Dorin. I would like connect only ONE keyframe to a slider control.
http://www.videocopilot.net/forum/viewtopic.php?f=5&t=121198

Expressions create dynamic links between properties, whereas scripts automate user interaction.

Therefore, expressions are not really conceived to change individual keyframes. However, if you’re talking about a boolean keyframe, there’s no reason why you can’t do it with a simple expression.

tVal = effect("Some Checkbox Effect")(1).value;
if(time >= thisProperty.key(2).time && time <thisProperty.key(3).time) tVal; else value;

If you’re not dealing with a boolean value, you can also do some simple easeIn, easeOut, easeEase or linear interpolation between certain keyframes… using the time elapsed between the keyframes as the input and the start and end values as the output. If you really know what you’re doing, you could write a cubic interpolation or a sine interpolation or even a bezier interpolation. I’m not going to go in to that here.

That last paragraph might all sound a little vague. It is. If you want me to be more specific, you’d have to be more specific about what you’re actually trying to achieve, otherwise, I’m just making stabs in the dark.

therealist said

Thank you for the fast reply. I have a totally same problem: "I made a video explanation. https://mega.co.nz/#!705BSYIA!FxGPjNPWEbTlxqL1m-ocyBPpwiB8iljAtHP7KmdWa8Q "

tKey1Val = 0; 
tKey2Val = thisComp.layer("Adjustment Layer 1").effect("Slider Control")(1).value; //your slider control
tDurationKey1ToKey2 = thisProperty.key(2).time-thisProperty.key(1).time;
tElapsedSinceKey1 = (time-thisProperty.key(1).time);
linear(tElapsedSinceKey1, 0, tDurationKey1ToKey2, tKey1Val, tKey2Val);

or boiling down those long winded variable names a bit…

P = thisProperty; 
K1 = 0; 
K2 = thisComp.layer("Adjustment Layer 1").effect("Slider Control")(1).value;
Dur = P.key(2).time-P.key(1).time;
E = time-P.key(1).time;
linear(E, 0, Dur, K1, K2);
//ease(E,0,Dur,K1,K2); // alternative to line above with easing.

Hi guys,i want to know what this expression says:

offset=thisComp.layer(“Controller”).effect(“Curve Depth”)(“Slider”)-1;
p=thisComp.layer(“Logo1”)
offsetInterval=Math.abs(index-thisComp.layer(“Logo1”).index);
[p.position[0],p.position[1],p.position[2]+(offset
offsetInterval)];

what do the Math.abs words do,in this expression also what is offsetInterval?

Thanks

farvahar said

Hi guys,i want to know what this expression says:

offset=thisComp.layer("Controller").effect("Curve Depth")("Slider")*-1;
p=thisComp.layer("Logo1")
offsetInterval=Math.abs(index-thisComp.layer("Logo1").index);
[p.position[0],p.position[1],p.position[2]+(offset*offsetInterval)];

what do the Math.abs words do,in this expression also what is offsetInterval?

Thanks

Math.abs takes the absolute value. In other words, it does nothing to positive numbers, but if they’re negative, it makes them positive (i.e. x -1)

offsetInterval is an arbitrary layer name. Its value is set to be the difference between the layer with the expression’s own layer number and the layer number of the “Logo 1” layer.

In other words, if the layer “Logo 1” has the layer number 10 and the layer with the expression has the layer number 6, offsetInterval will be 4. The Math.abs bit makes sure that the result is still 4 even if the layer numbers are swapped, so that “Logo 1” is layer 6 and the layer with the expression is layer 10.