Expressions/Scripts/Presets

Moderators: Disciple, zlovatt

 
dunkelzahn
Topic Author
Posts: 7
Joined: Wed Nov 16, 2011 4:14 am

Connecting In/Out Points with time remap

Wed Jan 22, 2014 2:33 am

Good morning everybody,

I am currently working on a AE project, where I want the In and out point of a layer to define the In and out point of another layer.

Something like this:

Layer 1 In Point/Out Point
I
I defines
I
I--> LAYER 2 In Point/Out Point


I guess using an expression that uses Time Remap on Layer2 might be helpful here, by positioning the keyframes at the in and out points of Layer 1. I have tried this approach to control the position of the two time remap keyframes in the comp:

timeRemap.key(1).valueAtTime = thisComp.layer("Layer 1").inPoint
timeRemap.key(2).valueAtTime = thisComp.layer("Layer 1").outPoint


However, nothing happens. I am doing something wrong, but I don´t know what :(. Any help on this topic, including nudges in the right direction are much appreciated.

Cheers and wishing all of you a nice day

Dunkelzahn
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Connecting In/Out Points with time remap

Wed Jan 22, 2014 6:31 am

Try this expression on the time remap property:
i = thisComp.layer("Layer 1").inPoint;
o = thisComp.layer("Layer 1").outPoint;
linear(time, i, o, thisLayer.inPoint, thisLayer.outPoint);
 
dunkelzahn
Topic Author
Posts: 7
Joined: Wed Nov 16, 2011 4:14 am

Re: Connecting In/Out Points with time remap

Fri Jan 24, 2014 9:39 am

Hey Mister Tuersley,

the code works like a charm... except for one little misunderstanding ;). I wanted the keyframes not to have the value but to be at the in and out points in the time line. Anyway, I´ll have a look if I can modify your little piece of code.

Cheers

Dunkelzahn
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Connecting In/Out Points with time remap

Fri Jan 24, 2014 9:53 am

Yeah I wasn't totally sure what you wanted. An expression can't actually alter the in/out points of a layer but you could have an Opacity expression to give the same effect:
i = thisComp.layer("Layer 1").inPoint;
o = thisComp.layer("Layer 1").outPoint;
if (time < i || time > o) 0;
else value;

If you wanted a Time Remap expression to shift the existing start/end keyframes based on the other layer you could modify my first example to:
i = thisComp.layer("Layer 1").inPoint;
o = thisComp.layer("Layer 1").outPoint;
linear(time, i, o, key(1).value, key(2).value);
 
dunkelzahn
Topic Author
Posts: 7
Joined: Wed Nov 16, 2011 4:14 am

Re: Connecting In/Out Points with time remap

Tue Jan 28, 2014 7:11 am

Oh wow,

that works great :). Thank you very much. This should make a lot of things easier.

Cheers and Best Wishes to you, where ever you may be, Mr. Tuersley :)

Dunkelzahn
 
dunkelzahn
Topic Author
Posts: 7
Joined: Wed Nov 16, 2011 4:14 am

Re: Connecting In/Out Points with time remap

Wed Sep 03, 2014 7:12 am

Hello everybody it´s me again,

I am just trying build another template, where there are 4 keyframes in the layer to be time remapped. This is due to the layer having an intro and an outro. So basically my script should look like this:

i1 = thisComp.layer("Layer 1").inPoint;
o1 = thisComp.layer("Layer 1").inPoint+4;
i2= thisComp.layer("Layer 1").outPoint-4;
o2 = thisComp.layer("Layer 1").outPoint;
linear(time, i1, o1, key(1).value, key(2).value);
linear(time, i2, o2, key(3).value, key(4).value);


But I am missing out on something, as either the first or last two keyframes are affected, depending on which linear argument comes first.

So how do I make the time remap accept all four keyframe instructions? Currently I am feeling a bit lost and am grateful for any tips leading me in the right direction.

Greetings and have a nice day

Dunkelzahn
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Connecting In/Out Points with time remap

Wed Sep 03, 2014 8:00 am

Something like this:

i1 = thisComp.layer("Layer 1").inPoint;
o1 = thisComp.layer("Layer 1").inPoint+4;
i2= thisComp.layer("Layer 1").outPoint-4;
o2 = thisComp.layer("Layer 1").outPoint;
if (time <= o1) linear(time, i1, o1, key(1).value, key(2).value);
else if (time >= i2) linear(time, i2, o2, key(3).value, key(4).value);
else linear(time, o1, i2, key(2).value, key(3).value);


Expressions are calculated on each frame with no knowledge of the result of other frames, so an expression must always evaluate to something on every frame. You can't just stack up various instructions like having multiple linear lines. Unless you use something like an if/else statement it will always result in the evaluation of the last line.
 
dunkelzahn
Topic Author
Posts: 7
Joined: Wed Nov 16, 2011 4:14 am

Re: Connecting In/Out Points with time remap

Wed Sep 03, 2014 8:33 am

Duly noted, that bit with the if/else logic for calculating stuff frame by frame gave me quite a lot to think about in terms of what is possible in terms of expressions. :idea:

Again, Thank you very much, Mr. Thursley :)

Cheers

Dunkelzahn

Who is online

Users browsing this forum: No registered users and 12 guests