Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression count up values in specific time

  • Expression count up values in specific time

    Posted by Hung Nguyendac on April 19, 2020 at 2:23 am

    Hello everyone. I’m trying this expression. But the problem is when i key Slider from 50->51->52. The value in source text change in a single frame. Is it possible to make the value count up in 1 second instead of 1 frame?
    x=Math.round(comp("MainComp").layer("Value Control").effect("Value 1")("Slider"));
    if(x==50) footage("Values.csv").dataValue([2,0]) else
    if(x==51) footage("Values.csv").dataValue([2,1]) else
    if(x==52) footage("Values.csv").dataValue([2,2]) else
    if(x==53) footage("Values.csv").dataValue([2,3]) else
    if(x==54) footage("Values.csv").dataValue([2,4]) else
    if(x==55) footage("Values.csv").dataValue([2,5]) else
    value

    TIA ☺

    Hung Nguyendac replied 6 years ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    April 19, 2020 at 4:41 am

    The key to making something like this work is that your expression has to be able to figure out when the slider changed to a particular value. Do you have a keyframe for each slider value? If so, it’s fairly straighforward. If not, it’s more cumbersome, but it can still be done. So how are you driving the slider values, exactly?

    Dan

  • Hung Nguyendac

    April 19, 2020 at 5:02 am

    Hi Dan.
    Yes. I have 1 Slider and about 30 Toggle Hold Keyframe on it.
    Each keyframe will get the value from csv file to Source Text.
    Currently, when I key Silder’s value from 50->51. The source text will change (500->1000) Immediately in 1 frame when the Slider’s value = 51.
    I’m looking for is it possible to make it change (500 count up to 1000) In 30 frames (1s) After each new keyframe of slider?

  • Dan Ebberts

    April 19, 2020 at 6:20 am

    It seems like the value of the slider doesn’t matter, just the index of the most recent keyframe. It will probably looks something like this:


    s = comp("MainComp").layer("Value Control").effect("Value 1")("Slider");
    v = value;
    if (s.numKeys > 0){
    n = s.nearestKey(time).index;
    if (time < s.key(n).time) n--;
    if (n > 0){
    if (n ==1){
    v = footage("Values.csv").dataValue([2,0]);
    }else{
    t = time - s.key(n).time;
    v1 = footage("Values.csv").dataValue([2,n-2]);
    v2 = footage("Values.csv").dataValue([2,n-1]);
    v = linear(t,0,1,v1,v2);
    }
    }
    }
    v

    Dan

  • Hung Nguyendac

    April 19, 2020 at 9:26 am

    Thanks a lot for your help Dan. I tried it and seem like expressions can not execute what i’m thinking, i’ll continue with old expression. Hope you are staying safe in the pandemic ????

  • Hung Nguyendac

    April 23, 2020 at 10:14 am

    Hi Dan. I’m facing a problem.
    Text 1. Source Text: It’s simple and working fine.
    x=thisComp.layer("Null 1").effect("Slider")("1");
    if (x==1) "Name 1" else if(x==2) "Name 2" else "Name 3"

    Text 2 . Source Text: The problem in line 3.
    n=Math.round(thisComp.layer("Text 1").text.sourceText)+".csv";
    x=Math.round(comp("MainComp").layer("Null 2").effect("Slider")("Slider"));
    if(x==50) footage(n).dataValue([2,0]) else value

    When i key Null 1 change from “Name 1” -> “Name 2”. But Text 2 can’t get “Name 2.csv” to n, After Effects shows error couldn’t find footage named NaN.csv.
    I’m trying to add “” to n by this if(x==50) footage((")+n+(")).dataValue([2,0]) else value. it’s wrong.
    Is there any way to make it work?

  • Hung Nguyendac

    April 23, 2020 at 10:18 am

    Hi Dan. I’m facing a problem.
    Text 1. Source Text: It’s simple and working fine.
    x=thisComp.layer(“Null 1”).effect(“Slider”)(“1”);
    if (x==1) “Name 1” else if(x==2) “Name 2” else “Name 3”

    Text 2 . Source Text: The problem in line 3.
    n=Math.round(thisComp.layer(“Text 1″).text.sourceText)+”.csv”;
    x=Math.round(comp(“MainComp”).layer(“Null 2”).effect(“Slider”)(“Slider”));
    if(x==50) footage(n).dataValue([2,0]) else value

    When i key Null 1 change from “Name 1” -> “Name 2”. But Text 2 can’t get “Name 2.csv” to n, After Effects shows error couldn’t find footage named NaN.csv.
    I’m trying to add “” to n by this
    if(x==50) footage((")+n+(")).dataValue([2,0]) else value . it’s wrong.
    Is there any way to make it work?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy