Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Retrieve value from sourcetext

  • Retrieve value from sourcetext

    Posted by Jorge Froberg on May 9, 2014 at 11:04 am

    Hi all,

    I have possibly a very simple question, but I can’t seem to figure it out and I have looked all over the interwebs for answer without result.
    In my composition I have a text layer with a number as sourceText. Now I want to use this number in another layer to scale accordingly.
    However, when I try to use the sourceText as a value, it gives me the following error message: Object of type TextProperty found where a Number, Array, or Property is needed. Below you can find the code I’m trying currently.

    Could anyone tell me what I’m doing wrong? How am I transforming the sourceText into a working value?

    Thanks,
    Jorge

    L1 = thisComp.layer("Text 1").text.sourceText;
    [transform.scale[0], L1];

    David Henderson replied 8 years, 5 months ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    May 9, 2014 at 3:34 pm

    You need to convert it from text to a number. Try it this way:

    L1 = thisComp.layer(“Text 1”).text.sourceText;
    [transform.scale[0],parseFloat(L1)];

    Dan

  • Jorge Froberg

    May 14, 2014 at 9:57 am

    Thanks Dan, this worked!

  • David Henderson

    December 7, 2017 at 7:52 pm

    Please pardon my JS ignorance, I’m a senior editor with highly limited AE expressions understanding.

    I’m trying to accomplish the simple task of having source tex drive scale on another layer ( to ultimately be controlled via text entry within Premiere via Live Text Templates).

    L1 = thisComp.layer(“Text 1”).text.sourceText;
    [transform.scale[0],parseFloat(L1)];

    I found this thread and tried to use the above expression, but its only scaling in the Y axis, and I need uniform X,Y scale values.

    I tried several modifications, including:
    [transform.scale[0,1],parseFloat(L1)];

    But still return the same result.

    I’m looking for the most basic, direct control of scale via text entry- as I hear that complex expressions bog down in the LTT – Premiere workflow.
    I’ve posted a similar question here on the Adobe AE forum:
    https://forums.adobe.com/thread/2422493

    Many thanks for any assistance!

    Cheers,
    D

    L1 = thisComp.layer("Text 1").text.sourceText;
    [transform.scale[0],parseFloat(L1)];

  • Dan Ebberts

    December 8, 2017 at 2:31 am

    Try it this way:

    txt = thisComp.layer(“Text 1”).text.sourceText;
    s = parseFloat(txt,10);
    [s,s];

    Dan

  • David Henderson

    December 12, 2017 at 11:23 pm

    Thank you Dan!

    My apologies for the delay in response.
    This works well, although i don’t understand it as well as the workaround I had come to.

    Can someone explain how this section works?

    s = parseFloat(txt,10);
    [s,s]

    specifically the (txt,10). I have no idea where the 10 comes in…. :/

    I’m assuming that this expressions is lighter weight than what I came to, as it only runs the parsefloat once?

    Fascinating and baffling stuff- thank you again Dan Ebberts 🙂

    SCALE = thisComp.layer("Desc. scale").text.sourceText;
    [parseFloat(SCALE),parseFloat(SCALE)];

  • Dan Ebberts

    December 12, 2017 at 11:33 pm

    Yikes, that’s a mistake. It should just be:

    s = parseFloat(txt);
    [s,s]

    You might use (txt,10) with parseInt(), but not parseFloat(). Good catch.

    And, yes, I do it that way so that you only have to parse the text once.

    Dan

  • David Henderson

    December 13, 2017 at 12:21 am

    Err- I wouldnt call it a catch so much as extra confusion!

    I tried different numbers than 10 (1, then 0) and it had no visual effect. I assumed it was a placeholder or something- but I clearly know nothing about expressions…

    Cool to know that I can use your simpler code. I had been wanting something to effectively ignore arrays ( or rather, populate all dimensions with one value – so I could have uniform x,y,z scale modifiers).

    Many thanks for all you do Dan 🙂

    s = parseFloat(txt);
    [s,s]

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