Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Eliminate decimal points of source text when tied to rotation?

  • Eliminate decimal points of source text when tied to rotation?

    Posted by Jake Scott on April 8, 2010 at 6:50 pm

    I have a text layer with the source text pick-whipped to another layers rotation value. I want the source text to update with the number of degrees when I rotate the layer.

    It works fine but it adds 13 numbers after the decimal point. Is there a way to update the source text expression so that it only reads one number after the decimal point instead of 13?

    Thank you for any help.

    Jake

    comp("Hill Start Assist Scn17").layer("truck side view.ai").transform.rotation

    Kricket Ro replied 12 years, 7 months ago 3 Members · 3 Replies
  • 3 Replies
  • Ben Rollason

    April 8, 2010 at 6:54 pm
    myNumber = 23.3453255243697978;
    round(myNumber, 2);
    
    function round(aNum, dP) {
           return(Math.round(aNum*Math.pow(10, dP))/Math.pow(10, dP));
    }
    

    you can also use myNumber.toFixed(2) but After Effects doesn’t always recognise numbers as numbers, in which case this will throw an error. This version will also pad the decimal places with zeros, which the above function won’t.

    -Ben.

    vfx.benrollason.com

  • Jake Scott

    April 8, 2010 at 7:23 pm

    WOW! Thanks for the quick response Ben. That worked perfectly.

    P.S. Amazing Demo Reel

  • Kricket Ro

    October 3, 2013 at 9:00 pm

    Ben, do you mind explaining that expression? What each element of the function means? Is there a way to make it a simpler expression? I’d like something short that is easy to remember. If possible.

    Thanks!

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