ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Retrieve value from sourcetext

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jorge Froberg
Retrieve value from sourcetext
on May 9, 2014 at 11:04:43 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];


Return to posts index


Dan Ebberts
Re: Retrieve value from sourcetext
on May 9, 2014 at 3:34:26 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



Return to posts index

Jorge Froberg
Re: Retrieve value from sourcetext
on May 14, 2014 at 9:57:33 am

Thanks Dan, this worked!


Return to posts index


David Henderson
Re: Retrieve scale value from sourcetext
on Dec 7, 2017 at 7:52:02 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)];


Return to posts index

Dan Ebberts
Re: Retrieve scale value from sourcetext
on Dec 8, 2017 at 2:31:20 am

Try it this way:

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


Dan



Return to posts index

David Henderson
Re: Retrieve scale value from sourcetext
on Dec 12, 2017 at 11:23:54 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)];


Return to posts index


Dan Ebberts
Re: Retrieve scale value from sourcetext
on Dec 12, 2017 at 11:33:38 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



Return to posts index

David Henderson
Re: Retrieve scale value from sourcetext
on Dec 13, 2017 at 12:21:34 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]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]