ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Loop out defined set of keyframes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jason Jantzen
Loop out defined set of keyframes
on Apr 6, 2014 at 4:13:51 am

Is there a way to loop just a set of keyframes, like maybe with markers or something? My basic set up has 3 keyframes and I'd like to loop out, but not include the first keyframe. Any ideas?

Jason Jantzen
vimeo.com/jasonj


Return to posts index


Dan Ebberts
Re: Loop out defined set of keyframes
on Apr 6, 2014 at 5:53:06 am

The second parameter of loopOut() controls how many keyframes get looped. This will loop the last two:

loopOut("cycle",1)


(the parameters specifies the number of keyframes in addition to the last one).


Dan



Return to posts index

Jason Jantzen
Re: Loop out defined set of keyframes
on Apr 7, 2014 at 2:42:30 pm

Thanks Dan! So if I understand this correctly, "numberKeyframes" defines which keyframe is the looping point, or simply how many are looped? Because with a value of 1, I'm a little confused that it's looping only 1 keyframe, since it's looping after the 1st keyframe, but not including it. Is there a number 0 keyframe in consideration with AE?

Jason Jantzen
vimeo.com/jasonj


Return to posts index


Dan Ebberts
Re: Loop out defined set of keyframes
on Apr 7, 2014 at 4:46:11 pm

For loopOut(,)the count is the number of keyframes to be looped, counting backwards from the last keyframe, but the last keyframe is not included in that count (it is included in the loop though). So if you have 3 keyframes, loopOut("cycle",1) loops keyframes 2 and 3. It is a little confusing.


Dan



Return to posts index

Jason Jantzen
Re: Loop out defined set of keyframes
on Apr 7, 2014 at 5:51:04 pm

Thanks Dan, that does help make sense of it.

Jason Jantzen
vimeo.com/jasonj


Return to posts index

Anton Frolov
Re: Loop out defined set of keyframes
on Dec 3, 2016 at 5:18:46 am

Hello Dan!
But what if I need to loopOut("cycle",-2) (tried to joke in IT)
I mean if I need the FIRST 3 keyframes to be looped until we reach the 4th keyframe (then goes the animation 5,6,7kf ...)?

Thanks!

Also tried to stop the lO(); with markers and continue ->
failed to insert reference to the property itself so it stops loopOut and reads the current Kframes. Only constant values work here =(
=====
stop = marker.key(marker.numKeys).time;
loopDur = key(numKeys).time;
if (time > stop){
stop%loopDur;
}else{
loopOut();
}


Return to posts index


Dan Ebberts
Re: Loop out defined set of keyframes
on Dec 3, 2016 at 11:27:15 pm

It's hard to decipher exactly what you're looking for, but it might be something like this:


if (numKeys >= 7){
if (time < key(1).time){
t = time;
}else if (time < key(4).time){
t = key(1).time + (time - key(1).time)%(key(3).time - key(1).time);
}else if (time < key(5).time){
t = time;
}else{
t = key(5).time + (time - key(5).time)%(key(7).time - key(5).time);
}
valueAtTime(t);
}else
value


It should loop keyframes 1 through 3 until it gets to keyframe 4, then when it gets to keyframe 5, it loops 5 through 7.
Hopefully there's enough there to get you headed in the right direction.


Dan



Return to posts index

Cutter Johnston
Re: Loop out defined set of keyframes
on Apr 20, 2017 at 1:07:26 pm

Dan,

Thank you for still being around. Could you take a look at this? When I add loopOut("cycle",7) to the end of the existing expression below it becomes in active. How can I LoopOut the keyframes and keep the slider expressions intact?

Thanks!

Cutter

a=wiggle(thisComp.layer("Slider Controls Body").effect("Pelvis X Amp")("Slider"),thisComp.layer("Slider Controls Body").effect("Pelvis X Movement")("Slider"));
b=wiggle(thisComp.layer("Slider Controls Body").effect("Pelvis Y Amp")("Slider"),thisComp.layer("Slider Controls Body").effect("Pelvis Y Movement")("Slider"));
[a[0],b[1]];


Return to posts index

Dan Ebberts
Re: Loop out defined set of keyframes
on Apr 20, 2017 at 4:29:12 pm

Are you just trying to add a wiggle to looped keyframes? Something like this might work:

a=wiggle(thisComp.layer("Slider Controls Body").effect("Pelvis X Amp")("Slider"),thisComp.layer("Slider Controls Body").effect("Pelvis X Movement")("Slider"));
b=wiggle(thisComp.layer("Slider Controls Body").effect("Pelvis Y Amp")("Slider"),thisComp.layer("Slider Controls Body").effect("Pelvis Y Movement")("Slider"));
loopOut("cycle",7) + [a[0],b[1]] - value;


Dan



Return to posts index


Cutter Johnston
Re: Loop out defined set of keyframes
on Apr 20, 2017 at 9:57:57 pm

Dan,

Amazing...perfection.

Thank you!

Cutter


Return to posts index

Cutter Johnston
Re: Loop out defined set of keyframes
on Apr 25, 2017 at 1:44:20 am

Dan,

Is there a clear line/script that can be added to the loopOut expression that will stop the cycle at a marker or frame number? I tested convert expression to keyframes but that is not efficient.

The solutions in the Stop loopOut [Nov 2009] post did not seem to work.

Cutter


Return to posts index

Cutter Johnston
Re: Loop out defined set of keyframes
on Apr 25, 2017 at 2:41:58 am

To Be Clear:

The loopOut in the script below works beautifully:

a=wiggle(thisComp.layer("Slider Controls Body").effect("Pelvis X Amp")("Slider"),thisComp.layer("Slider Controls Body").effect("Pelvis X Movement")("Slider"));
b=wiggle(thisComp.layer("Slider Controls Body").effect("Pelvis Y Amp")("Slider"),thisComp.layer("Slider Controls Body").effect("Pelvis Y Movement")("Slider"));
loopOut("cycle",7) + [a[0],b[1]] - value;


The goal is to have the ("cycle") stop at frame or marker "?" to frame or marker "?" and change the movement between designated markers or frame numbers. Then pick up the original ("cycle") again from frame or marker "?" to frame or marker number "?".

If it is simpler to edit comps together so be it.


Return to posts index


Dan Ebberts
Re: Loop out defined set of keyframes
on Apr 25, 2017 at 3:18:27 am

I'm having a hard time picturing what you're describing.

Dan



Return to posts index

Cutter Johnston
Re: Loop out defined set of keyframes
on Apr 25, 2017 at 11:28:53 am

Scenario:

  • A rigged character is dancing to an audio track for 1100 frames [timeline set to frames] using loopOut in the slider expression you assisted with.

  • At frame 299 I want the loop to stop for 100 frames [300-400] and change the movement.

  • At frame 401 the character picks up the initial loopOut movement for another 300 frames.

  • Then again at frame 702 the loopOut stops again for another 100 frames and the movement changes again.

  • This pattern continues through to the end of the audio track.


  • The frame numbers provided are just for illustration. Markers can be used if it is simpler. There are seven characters in the animation and they need to move as a group. It would be VERY efficient to "cut and paste" an expression into the characters 6 controller layers of each characters comp timeline. That way, refinements/changes to the movement will be confined to the sections of the timeline where the loopOut has been disabled and will not effect the overall timing of the choreography as their timing needs to be in sync. I often mistakenly shift keyframes.

    I hope this helps. I have a manually keyed clip if you need it.

    Cutter


    Return to posts index

    Dan Ebberts
    Re: Loop out defined set of keyframes
    on Apr 27, 2017 at 11:18:52 pm

    During the non-loopOut parts, what controls the movement (other keyframes?)? How do you make sure there isn't a jump in the motion if you stop or start in the middle of a loop?



    Return to posts index

    Cutter Johnston
    Re: Loop out defined set of keyframes
    on Apr 27, 2017 at 11:45:29 pm

    The keyframes ONLY happen every 6 frames in all instances of every layer through out the animation. [Done to keep in sync with the beats per minute of the audio track] Ideally the stopping of the loopOut will be set to occur at the proper frame or marker. If this is not possible I will replicate/key-in the required keyframes for a smooth stop. But mathematically this seems very possible. I just do not have high enough understanding of expressions.

    I read a post on CC that loopOut could be stopped at a frame or marker but I have been unable to add that expression or parts of it successfully. Below are the expressions from that post:

    stop = marker.key(marker.numKeys).time;
    loopDur = key(numKeys).time;
    if (time > stop){
    stop%loopDur;
    }else{
    loopOut();
    }


    And the other variation in the same post

    loopOut(type = "cycle", numKeyframes = 0)
    stop = marker.key(marker.numKeys).time;
    loopDur = key(numKeys).time;
    if (time > stop){
    stop%loopDur;
    }else{
    loopOut();
    }


    Thanks!


    Return to posts index

    Dan Ebberts
    Re: Loop out defined set of keyframes
    on Apr 28, 2017 at 1:43:21 am

    My guess is that this is tricky but do-able. I think there are still too many unknowns though to be able to launch into it and get it right.

    Dan



    Return to posts index

    Cutter Johnston
    Re: Loop out defined set of keyframes
    on May 1, 2017 at 12:48:14 pm

    No problem...I will proceed with the seamless editing I have been using. Look for the finished product soon. Thanks!

    Cutter


    Return to posts index

    Cutter Johnston
    Re: Loop out defined set of keyframes
    on Apr 27, 2017 at 10:21:59 pm

    Scenario:

  • A rigged character is dancing to an audio track for 1100 frames [timeline set to frames] using loopOut and the slider expression you assisted with.

  • At frame 299 I want the loop to stop for 100 frames [300-400] and change the movement

  • At frame 401 the character picks up the initial loopOut movement for another 300 frames

  • Then again at frame 702 the loopOut stops again for another 100 frames and the movement changes again.

  • This pattern continues through to the end of the audio track.


  • The frame numbers provided are just for illustration. Markers can be used if it is simpler. There are seven characters in the animation and they need to move as a group. It would be VERY efficient to "cut and paste" an expression into the characters 6 controller layers of each characters comp timeline. That way, refinements/changes to the movement will be confined to the sections of the timeline where the loopOut has been disabled and will not effect the overall timing of the choreography as their timing needs to be in sync. I often mistakenly shift keyframes.

    I have a manually keyed clip if you need it.

    Cutter


    Return to posts index

    Cutter Johnston
    Re: Loop out defined set of keyframes
    on Apr 27, 2017 at 10:22:51 pm

    Sorry for the late reply...this sat in the Preview Window for days!


    Return to posts index

    Darby Edelen
    Re: Loop out defined set of keyframes
    on Dec 5, 2016 at 3:30:20 am

    I can't decipher the expression you included, but based on your description it sounds to me like you just need:

    loopIn("cycle", 2);

    Darby Edelen


    Return to posts index

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