The Expressions Thread

Nevermind! I just realized a better way to do this. I was trying to make an expression to make easy for buyers to change the end time of an specific item (a lower third in my case) by using 1 marker.

What I did was I put this expression in the time remap effect of the lower third composition. The time remap have only 2 keyframes (one for 0 and another for the exact moment when the animation starts to end)

Resuming, This:

Probably it could be better, but I'm noob with expressions. Aniway, here is the expression, maybe it will be useful for someone else (:

if(time >1.6){ // time before intro animation
action = thisComp.layer("YOURLAYERNAME");

n = 0;

if (marker.numKeys > 0){

n = marker.nearestKey(time).index;

if (marker.key(n).time > time){

n–;

}

}

if (n == 0){

2.17 // animation will keep freeze at this choosen time

}else{

k = 0;

if (numKeys > 0){

k = key(2).time;

}

m = marker.key(n);

t = time - (m.time - k); // time at the marker will be the time of the 2Âș keyframe

}

}
else{value}

MotionIdea said

Hello guys, is it possible to set a specific time to start at a layer marker ?

For example:

time flows normally :
1s,2s,3s,4s,5s


Then, when the time indicator reachs the marker it jumps to 30s and flows from that point:
30s,31s,32s,33s


Is it possible ?

For this simple scenario, you only need a single line of code on the Time Remap property.

if(marker.numKeys) {time>=marker.key(1).time ? 30+(marker.key(1).time-time) : value} else value;

The ? and : part is a ternary expression and is a useful shorthand way of writing an if else statement.

felt_tips said
MotionIdea said

Hello guys, is it possible to set a specific time to start at a layer marker ?

For example:

time flows normally :
1s,2s,3s,4s,5s


Then, when the time indicator reachs the marker it jumps to 30s and flows from that point:
30s,31s,32s,33s


Is it possible ?

For this simple scenario, you only need a single line of code on the Time Remap property.

if(marker.numKeys) {time>=marker.key(1).time ? 30+(marker.key(1).time-time) : value} else value;

The ? and : part is a ternary expression and is a useful shorthand way of writing an if else statement.

Ternary expression — always wanted to know that! Thanks.

Andrew_Belov said
felt_tips said

Make a 3D layer called Solid 1 in a comp called Comp 1. Pre-comp it moving attributes. Make the layer created 3D, collapsed and call it “Pre-comp”. Inside precomp, make a 3D Point Control effect (I think this exists in CS5.5) and call it “world vec”. On this effect use the expression


thisLayer.toWorldVec([0,0,1]); 

This makes sure that the toWorldVec calculation is taking place with respect to the world space inside that comp. (which of course is the same as the layer space of the layer “Pre-comp”).

Then, make a Tint effect on the layer “Pre-comp”. On the Amount to Tint property do this


v = thisLayer.source.layer("Solid 1").effect("world vec")(1); //pick up the world coords from the effect
vWrld = thisLayer.toWorldVec(v);
vecCamToLyr = normalize(thisLayer.toWorld(thisLayer.anchorPoint)-thisComp.activeCamera.toWorld([0,0,0]));
dot(vecCamToLyr, vWrld)>0 ? 100 : 0;

I’m using the dot product, because toCompVec seems to be unreliable with any vector other than [0,0,1]. Not quite sure why. I’d need to spend some time testing it. The dot product compares the orientation of the calculated vector in world space and the vector from the camera to the layer.

I’m being a bit rushed with this, 'cos I’ve got lots to do, but hopefully this will work. It seemed to work when I gave it a quick test.

How to rewrite these expressions that overlay Tint effect several layers in “Pre-comp” ?
“Pre-comp” consists of several 3D layers, each of which is overlay Tint.

Hi Andrew,

I can’t remember what the original question was in the post you quoted and I don’t really understand your question. Can you explain what you’re trying to achieve?

Andrew_Belov said
felt_tips said

Hi Andrew,
I can’t remember what the original question was in the post you quoted and I don’t really understand your question. Can you explain what you’re trying to achieve?

Hi. This thread began with the post:
How to make a layer invisible when facing away from camera ? I found a few solutions for different cases but not for all..Please help! :)

Level I: Just a 3D layer
if (toCompVec([0, 0, 1])[2] > 0 ) value else 0

Level II: Pre-compose 3D layer
value*normalize( dot(toWorldVec([0,0,1]),normalize(comp(‘MainComp’).activeCamera.toWorld([0,0,0])-toWorld(anchorPoint))));

Level III: Pre-compose 3D layer AND composition rotation
???

You found solutions for Level III. I need to solve for Level 4: In Pre-compose several rotating 3D layers AND Pre-compose in Comp1 rotation

The code is very precise. Your description needs to be very precise too. You need to describe the exact structure of your project or you need to make a project file available.

felt_tips said

The code is very precise. Your description needs to be very precise too. You need to describe the exact structure of your project or you need to make a project file available.

https://www.dropbox.com/s/mxj0q6eqcoftohc/Precomp%20two%20sided%20layers.aep?dl=0
I want to rotate a “Pre-comp” layer in Comp 1 and that layers be two sided.

FlyRey said
felt_tips said

The code is very precise. Your description needs to be very precise too. You need to describe the exact structure of your project or you need to make a project file available.

https://www.dropbox.com/s/mxj0q6eqcoftohc/Precomp%20two%20sided%20layers.aep?dl=0
I want to rotate a “Pre-comp” layer in Comp 1 and that layers be two sided.

Thanks
 I’ll have a look at the weekend.

MotionIdea said

Nevermind! I just realized a better way to do this. I was trying to make an expression to make easy for buyers to change the end time of an specific item (a lower third in my case) by using 1 marker.

What I did was I put this expression in the time remap effect of the lower third composition. The time remap have only 2 keyframes (one for 0 and another for the exact moment when the animation starts to end)

Resuming, This:

Probably it could be better, but I'm noob with expressions. Aniway, here is the expression, maybe it will be useful for someone else (:

if(time >1.6){ // time before intro animation
action = thisComp.layer("YOURLAYERNAME");

n = 0;

if (marker.numKeys > 0){

n = marker.nearestKey(time).index;

if (marker.key(n).time > time){

n–;

}

}

if (n == 0){

2.17 // animation will keep freeze at this choosen time

}else{

k = 0;

if (numKeys > 0){

k = key(2).time;

}

m = marker.key(n);

t = time - (m.time - k); // time at the marker will be the time of the 2Âș keyframe

}

}
else{value}

Thanks!
MotionIdea

Show me an example how to use “and” in if expresision: if bla bla and bla bla 


Hi, everybody. There is a function in AE - when you create a project in CS5.5 you can save a copy as CS5. Is it possible to do the same thing with FFX animation presets? Or presets created in CS5.5 can be opened in CS5 without some special way of saving?

VadimGr said

Hi, everybody. There is a function in AE - when you create a project in CS5.5 you can save a copy as CS5. Is it possible to do the same thing with FFX animation presets? Or presets created in CS5.5 can be opened in CS5 without some special way of saving?

Never done this but when I think of it this seems a logical solution:

  1. Apply the preset in CS5.5, save project as CS5.

  2. Open the project in CS5.

  3. Select all effects and properties that make up your .ffx preset.

  4. Go to: Animation > Save preset.

Edit: sorry just re-read your initial post. No I don’t think there is any other way to open new .ffx presets in older versions.

motionvids said
VadimGr said

Hi, everybody. There is a function in AE - when you create a project in CS5.5 you can save a copy as CS5. Is it possible to do the same thing with FFX animation presets? Or presets created in CS5.5 can be opened in CS5 without some special way of saving?

Never done this but when I think of it this seems a logical solution:

  1. Apply the preset in CS5.5, save project as CS5.

  2. Open the project in CS5.

  3. Select all effects and properties that make up your .ffx preset.

  4. Go to: Animation > Save preset.

Edit: sorry just re-read your initial post. No I don’t think there is any other way to open new .ffx presets in older versions.

Yes, the problem is I don’t have CS5, so when I open a file saved as CS5, it automatically converts back to CS5.5. It looks like you’re right and there’s no other way.

Thank you for your answer.

I’ve been looking at MotionIdea’s expression (on the last page) for using a Marker to begin an ‘end’ animation, based on Time Remapping the layer’s pre-comp.

Is there a way of using a Marker to instruct a layer to actually ANIMATE OUT (using its position values) without using Time Remapping or pre-comps?

Time Remapping only helps if nothing moves (in the pre-comp) whilst we wait for the END marker.

So, at the Marker “END” (a Comp Marker would be best) the Layer would move from its current position (value) to a second position (eg. -1920 on ‘x’) over 10 frames, for instance, WITH an Ease Out.

Using a Comp Marker (as opposed to a Layer Marker) would allow multiple layers to act at the same mark but be individually adjustable, in terms of their final position and time taken (ie. 10 frames).

I have searched everywhere for this!

Not to worry, I’ll check on the Cow’s forum.

This thread seems retroactive.

Hi. I want to build a script that assigns a labeled layer to another layer. Is it possible? For now I do this through the control layer with expression. Thanks for the answer.

GrandTerr said

Show me an example how to use “and” in if expresision: if bla bla and bla bla 


Here’s an example I’m using right now on a layer’s opacity-

val1=thisComp.layer(“layer1”).transform.opacity;
val2=thisComp.layer(“layer2”).transform.opacity;
if (val1 == 0 && val2 == 0){
100
}else{
0
};

If the opacity on layer1 and layer2 equals 0 my layer’s opacity will be 100 otherwise 0.

||+1229179|FluxVFX-templates said-||
GrandTerr said

Show me an example how to use “and” in if expresision: if bla bla and bla bla 


Here’s an example I’m using right now on a layer’s opacity-

val1=thisComp.layer(“layer1”).transform.opacity;
val2=thisComp.layer(“layer2”).transform.opacity;
if (val1 == 0 && val2 == 0){
100
}else{
0
};

If the opacity on layer1 and layer2 equals 0 my layer’s opacity will be 100 otherwise 0.

Thanks, I used “and” instead of “&&”


What does this mean? :shocked:

HI,

I want to connect my AE source text to external file(like .txt or .doc). I tried to search but could not get any expression. Can you please help? TIA

indrasiva said

HI,

I want to connect my AE source text to external file(like .txt or .doc). I tried to search but could not get any expression. Can you please help? TIA

Take a look at this article!