Skip to main content
Participant
April 9, 2015
Answered

keyframes control with layer markers

  • April 9, 2015
  • 1 reply
  • 4739 views

Hello,

I have an animation of a line that has two sets of keyframes of two different properties in CS4.

Basically a line gets generated in the first phase then it gets cleared out in the second phase.

This is done using two slider controls that act on the horizontal size of two rectangles and using merge paths (using the second rectangle as a matte for the first to clear it out)

I've put two layer markers on my layer hoping to link the keyframes to each of them.

Then I have found this script on the web and I put it on the first property :

L= thisComp.layer("ShapeLayer");

n = 0;

if (L.marker.numKeys > 0){

n = L.marker.nearestKey(time).index;

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

n--;

}

}if (n == 0){

valueAtTime(0);

}else{

t = time - L.marker.key(n).time;

valueAtTime(t)

}

This indeed lets me move the whole animation with the layermarker (which is very good) but I can't find a way to link the second set of keyframes to do the output.

I will add a link with the project file: WeTransfer

Please help!

Thanks

This topic has been closed for replies.
Correct answer Dan Ebberts

I think this on your LenghtAnimate slider:

L= thisComp.layer("Line_Center_Reveal");

m = L.marker.key("In");

if (time < m.time){

  valueAtTime(0);

}else{

  t = time - m.time;

  valueAtTime(key(1).time + t);

}

and this one the OutAnimate slider:

L= thisComp.layer("Line_Center_Reveal");

m = L.marker.key("out");

if (time < m.time){

  valueAtTime(0);

}else{

  t = time - m.time;

  valueAtTime(key(1).time + t);

}

will do what you're looking for.

Dan

1 reply

Mylenium
Legend
April 10, 2015

It works no different, but of course you will have to explicitly reference the markers by index or name instead of just using the closest one to your current time. Si instead of:

L.marker.nearestKey(time).index


You would use


L.marker(1)


and so on.


Mylenium

Participant
April 10, 2015

First, thank you for taking the time to solve this.

I feel like a handicapped... and I am when it comes to scripting. (I'm not really a handicapped person (not that there's anything wrong with that))

It has been now over two hours of tweaking and replacing values...no go.

I can follow the logic behind the script - telling to use the index or the name of the marker instead of the nearest one but I'm a script retard.

So, like a child, I'm asking what does this do:

t = time - L.marker.key(n).time;  ?

and

should there be a dot between L.marker  and (1)  like this L.marker.(1)  ?

and there are many other questions (very stupid ones) that I will not mention here.

If you (me) don't have some basic knowledge about scripting, you (you) can give me everything word by word and I still wouldn't know how to assemble it in a script.

By now I think I've already made a fool of myself so the variable shame is not of the importance anymore.

I know...I shouldn't even be in this forum with my knowledge regarding the scripts in AE, but here I am.

I'm a motion graphic designer with over 15 years of experience with AE, and so far I've managed to elude the tricky part of learning scripting. (my bad)

If anybody has a question about motion graphics, or just graphics (ex. Oh my God, how did they do that in AfterEffects or Cinema 4D, Maya, Photoshop, Illustrator ?(or What do you think about this font, should I use it on my wedding invitation ?)) I will be glad to help!

Thank you everyone!

You are a great community!

exit.(stage(left))

}

P.S. (post.scriptum) I'm sorry if this turned into some kind of written stand up comedy but I didn't know how to approach this situation otherwise. I'm sorry about the retards too.(me included)

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
April 11, 2015

I think this on your LenghtAnimate slider:

L= thisComp.layer("Line_Center_Reveal");

m = L.marker.key("In");

if (time < m.time){

  valueAtTime(0);

}else{

  t = time - m.time;

  valueAtTime(key(1).time + t);

}

and this one the OutAnimate slider:

L= thisComp.layer("Line_Center_Reveal");

m = L.marker.key("out");

if (time < m.time){

  valueAtTime(0);

}else{

  t = time - m.time;

  valueAtTime(key(1).time + t);

}

will do what you're looking for.

Dan