Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Display numbers with set positions/kerning?

  • Display numbers with set positions/kerning?

    Posted by Ocean Byrne on September 11, 2014 at 5:00 am

    I have a variety of on screen displays, that are driven by data from an excel spreadsheet. I created several Effect/Expression Control/Sliders, and copy/pasted my data in to them. Then I created a text layer, made it’s Source Text an expression and pickwhipped it to my slider, so it reads out my data (and interpolations between my data points) and it is generally, pretty freakin cool.

    Except, I don’t like the kerning. I want it to be like a digital clock display, where each digit has a set position. Right now, my text is right justified, so if the number is 231 the 2 and 3 move to the right as opposed to 230, since 0 is bigger than 1 (doesn’t seem like that sentence should make any sense, but there it is.)

    Is there a way I can tell my text layer to leave 100 pixels between each digits right justify, regardless of what the digit is?

    Alternately, I could make 3 separate text layers A, B, C, and position them where I want – but how do I tell them to look at the slider currently = 231, and make A=2, B=3, C=1? And will A and B freakout when the slider value is 4?

    Dan Ebberts replied 11 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Ocean Byrne

    September 11, 2014 at 7:02 pm

    Well, I would still love to hear from someone if there is a way to specify and lock the kerning on your text to hold the digits in place?

    But, I bastardized a few other folks expressions, and came up with a rig where I have 3 separate text layers positioned where I want them, and then they use this expression to pull just the digit they want from the same slider.

    This expression absolutes away any decimals in your input value, and converts 23 to 023, or 00023 depending on your amtOfZeroes. Then on each text layer change the digit value to be the one you want to display.

    nums = thisComp.layer("Datas").effect("Altitude ft")("Slider");
    amtOfZeroes = 3; //how many digits do you want to see
    digit = 2; //digit to display, 0 is left most

    //--Do not modify below this line
    isNeg = false;
    if(nums < 0)
    {
    nums = Math.abs( nums );
    isNeg = true;
    }
    sVal = Math.round( nums ) + "";
    while(sVal.length < amtOfZeroes)
    {
    sVal = "0" + sVal;
    }
    if(isNeg)
    sVal = "-" + sVal;

    sVal.substr( digit , 1 )

  • Dan Ebberts

    September 11, 2014 at 7:10 pm

    The only thing I can think of would be to set up a crazy tracking expression using an expression selector that picks the tracking for each source text character out of an array. I haven’t tried it, but I think it would work.

    I would probably just use a mono-spaced font instead.

    Dan

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