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

Is there a loop expression for "full cycles" only?

Community Beginner ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

Hey, I'm making an animation bank.
As it is a bank and I will use it for various projects, I want the assets to be as editable as possible.
Each assets consists three comps - start, body (loop), and ending, so I could alter the length of the asset as I please.
the body comp is a single, cycle type, loop, which the loop expression is configured on its Time Remap value.
I know that you can limit the cycles based on a timestamp, but is there an expression that makes the loop go only in full cycles depends on the layer length?

 

for example: a layer is 5:00 sec in length, the looped keyframes are 2:00 sec in total.

In that scenario the loop will have 2.5 cycles, but I want the expression to recgonize that after 2 loops it won't be able to complete a third cycle so it will freeze on the last frame

for clarifications I use LoopOut exxpression on all of those said layers.

Thank you!

TOPICS
Expressions

Views

240

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

Community Beginner , Aug 15, 2024 Aug 15, 2024

Thank you so much Dan!
 I have changed (thisComp.duration - key(1).time) to (thisLayer.outPoint - thisLayer.inPoint) so the loop will end based on the layer duration and not the whole comp which is located in.
So the full expression is:

loopDur = key(numKeys).time - key(1).time;
numLoops = Math.floor((thisLayer.outPoint - thisLayer.inPoint)/loopDur);
if (time < key(1).time + numLoops*loopDur)
  loopOut()
else
  key(numKeys).value;

Thank you so much!

Votes

Translate

Translate
LEGEND ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

Not with this method. You would have to use valueAtTime() and write your own loop code.

 

Mylenium 

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

Try this time remapping expression:

loopDur = key(numKeys).time - key(1).time;
numLoops = Math.floor((thisComp.duration - key(1).time)/loopDur);
if (time < key(1).time + numLoops*loopDur)
  loopOut()
else
  key(numKeys).value;

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 Beginner ,
Aug 15, 2024 Aug 15, 2024

Copy link to clipboard

Copied

LATEST

Thank you so much Dan!
 I have changed (thisComp.duration - key(1).time) to (thisLayer.outPoint - thisLayer.inPoint) so the loop will end based on the layer duration and not the whole comp which is located in.
So the full expression is:

loopDur = key(numKeys).time - key(1).time;
numLoops = Math.floor((thisLayer.outPoint - thisLayer.inPoint)/loopDur);
if (time < key(1).time + numLoops*loopDur)
  loopOut()
else
  key(numKeys).value;

Thank you so much!

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