Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions source text return 3 values and include a + for positive values via a rotation slider

  • source text return 3 values and include a + for positive values via a rotation slider

    Posted by John Burgess on August 2, 2020 at 11:24 am

    Hello, I have source text tied to 3 slider controls that are controlling rotation across 3 axis. What I am trying to do is force 3 values including + and – so there are always 4 characters and avoids jumping around when changing.

    what I currently have looks like this…

    -50X
    3Y
    360Z

    and I want to achieve this…

    X-050
    Y+003
    Z+360

    I got a far as using using Math.round and +value but can’t figure out how to add the extra numbers in and include a + for positive values. I was also struggling to get +value to work at the start as opposed to the end. Thanks for any help.

    Math.round(effect("Y rotation")("Slider"))+value

    John Burgess replied 3 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    August 2, 2020 at 1:48 pm

    Something like this:

    y = Math.round(effect("Y rotation")("Slider").value);

    "Y" + (y < 0 ? "-" : "+") + ("00"+Math.abs(y)).slice(-3);

  • John Burgess

    August 2, 2020 at 1:57 pm

    Thanks so much Filip, that worked perfectly

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