Skip to main content
Participant
January 26, 2024
Question

An expression that adds up

  • January 26, 2024
  • 1 reply
  • 187 views

Hello,

I'm trying to find out if there's an expression that adds up every X images?

The problem:
A machine that 2 times per second will increase its value by 88kg.
In other words, a calculation that would add the imposed figure of 23604 by 88 every 12 images.

As I couldn't find this calculation, I did it by hand ^^, but I'd still like to find a less restrictive solution.

Thanks

This topic has been closed for replies.

1 reply

Community Expert
January 26, 2024

If you start by subtracting the layer's inPoint from the time, then divide that number by the interval and use Math.floor() to keep the value a whole number, you will get an even number multiplier you can use to add that value to a starting number. The expression is fairly simple. Add it to a text layer/Text property and you have your counter.

t = time - inPoint;
count = t / .5; // interval time in seconda
num = Math.floor(count);
step = 88 * num; // value increase
strt = 23604 + step; // starting Number
result = strt + "kg"

To keep the numbers from bouncing around, you will need to use a monospaced font like Courier;

 

 

 

Participant
January 26, 2024

Thank you very much! It works perfectly 🙂