• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Possible to Set a Limit to loopOut Cycles?

Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

I've got a composition with a few layers of precomps. I enabled Time Remapping on each and added this script:
loopOut(loop="cycle",numKeyframes=0)
Works great. I'd love to be able to limit the number of times the animation loops, though. Is that possible?
Thanks much!

TOPICS
Expressions , How to , Scripting

Views

2.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Sep 02, 2023 Sep 02, 2023

Hi!

Dan's expression is wonderful but I am wondering is it possible to add an option to it? I want to be able to set the range of the loopOut so it only affects the kyframes within that range. Let's say I have an object and it does this:

1) At the beginning of the comp it changes its position couple of times (no loop needed)

2) In the middle of the comp it jumps and I want to loop this jump 5 times using Dan's expression

3) At the end of the comp the object changes it position couple of times (no lo

...

Votes

Translate

Translate
Community Expert ,
Sep 05, 2023 Sep 05, 2023

Copy link to clipboard

Copied

Actually, this is better because it lets you define any number of loop areas with comp marker pairs and you don't have to modify the expression:

nLoops = 2;

m = thisComp.marker;
t = time;
if (m.numKeys > 1){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0 && ! (n%2)){
    t1 = m.key(n-1).time;
    t2 = m.key(n).time;
    loopDur = t2 - t1;
    if (time > t1 && time < t1 + nLoops*loopDur){
      t = t1 + (time - t1)%loopDur;
    }
  }
}
valueAtTime(t)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 05, 2023 Sep 05, 2023

Copy link to clipboard

Copied

Last expression is indeed the most practical but I can't set different loop counts for every animation. Every animation in the comp has a fixed duration.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2023 Sep 05, 2023

Copy link to clipboard

Copied

I'm not sure what you mean by the last part.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 05, 2023 Sep 05, 2023

Copy link to clipboard

Copied

Check out the screenshot. I want to be able to put multiple different loops made from different set of keyframes. In this example there are two loops that differs in duration. And that's exactly what I want and I would like to be able to have even more loops.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2023 Sep 06, 2023

Copy link to clipboard

Copied

Your screenshot shows a couple of sets of keyframes you want to loop. There may not be enough time between the first set of keyframes and the second set of keyframes for two loops to take place, but there is definitely not enough time between the second set of keyframes and the two keyframes at the end of the timeline for four more loops.

 

I don't have a suggestion for the expression, but I just wanted to point that out incase another user was confused.

 

I would also suggest you not use the Drag & drop here button for screenshots. You can copy and paste or drag them to the reply field so you can see them when writing a post, or even use the Toolbar to embed the images. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2023 Sep 06, 2023

Copy link to clipboard

Copied

LATEST

This is the only thing I can think of. With this version, you can specify the number of loops with the comment of the first marker of the marker pair. If you don't put a number in the marker comment, the expression will use what you have defined for nLoops:

nLoops = 2;

m = thisComp.marker;
t = time;
if (m.numKeys > 1){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0 && ! (n%2)){
    t1 = m.key(n-1).time;
    t2 = m.key(n).time;
    loopDur = t2 - t1;
    c = m.key(n-1).comment;
    nL = (c != "" && ! isNaN(parseInt(c))) ? parseInt(c) : nLoops;
    if (time > t1 && time < t1 + nL*loopDur){
      t = t1 + (time - t1)%loopDur;
    }
  }
}
valueAtTime(t)

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines