Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expressions in “source text”

  • Expressions in “source text”

    Posted by Hannes Paulsson on April 1, 2011 at 11:43 am

    Hi!

    So, what I want to do is to make a textlayer show the percents in a pie shart.
    I have a textlayer, and in the properties for “Source text” i have pickwhipped the value for a angle-controll. It works fine, i get the amount I want in text. But, i would like it to also say %.

    So, to clarify, how do I add the symbol % in the same textlayer that gets its value from a angle control.

    Right now the expression says:
    thisComp.layer(“Null 1”).effect(“Blue_bit”)(“Angle”)
    How do I add a %-symbol at the end?

    Michael Josefik replied 14 years, 2 months ago 3 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    April 1, 2011 at 1:13 pm

    This should do it:

    “” + thisComp.layer(“Null 1”).effect(“Blue_bit”)(“Angle”) + “%”

    Dan

  • Hannes Paulsson

    April 6, 2011 at 12:47 pm

    Thanks Dan, works like a charm!

  • Michael Josefik

    April 17, 2011 at 4:54 pm

    This thread was very helpful in a similar issue that I had, however I was wondering if you could expand on it. What if, using this example, you wanted the number to be orange, and you wanted the %-symbol to be black? Can you achieve color change within one line of text using expressions?

  • Dan Ebberts

    April 17, 2011 at 5:37 pm

    You could add a Fill Color animator, set the Fill Color to orange, add an Expression Selector, delete the Range Selector, and set the Expression Selector Amount parameter expression to this:

    str = text.sourceText;
    if (str[textIndex-1] == “%”)100 else 0

    Dan

  • Michael Josefik

    April 18, 2011 at 4:12 am

    Awesome, thank you so much.

  • Michael Josefik

    March 16, 2012 at 3:03 pm

    Hello again,
    I am trying to implement this expression again, but this time I want to have a “$” in front of numbers that are generated by a slider. I have written the expression below using what I learned in the first round.

    v = (thisComp.layer(“Adjustment Layer 1”).effect(“Slider Control”)(“Slider”));
    “” + “$” + v

    This however does not work. If I move the $ to the end…

    v = (thisComp.layer(“Adjustment Layer 1”).effect(“Slider Control”)(“Slider”));
    “” + v + “$”

    It works perfectly. What gives?

    Thanks

  • Dan Ebberts

    March 16, 2012 at 4:40 pm

    There’s an obscure behavior for expression controls where sometimes the expression engine will implicitly grab the value and sometimes it won’t (it thinks you’re referring to the slider object, no its value, for example). In those cases, you have to explicitly tell it to retrieve the value with “.value”. This will work:

    v = thisComp.layer(“Adjustment Layer 1”).effect(“Slider Control”)(“Slider”).value;
    “$” + v

    Dan

  • Michael Josefik

    March 16, 2012 at 9:40 pm

    That did the trick. Thanks again for saving a project!

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