ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression that recognises 2 lines of text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Deanna Keogh
Expression that recognises 2 lines of text
on Mar 14, 2019 at 5:55:09 am

Hi,

Im trying to create a text box, using sourceReactAtTime that follows my text based on how many characters and lines there are. I've used this tutorial:




Which is very helpful but seeing as my expression knowledge isn't vast I'm not sure how to word my code to allow the shape layer to clip to line one and use possibly another to clip to line two.

What I have:



Vs

What I want it to look like:



I hope that this makes sense.
These are the expressions that I am using that Ive gotten from the tutorial

var s = thisComp.layer("Subtitles");
var w = s.sourceRectAtTime().width/2;
var h = s.sourceRectAtTime().height/2;
var l = s.sourceRectAtTime().left;
var t = s.sourceRectAtTime().top;

[w+l,h+t]


Return to posts index

Scott McGee
Re: Expression that recognises 2 lines of text
on Mar 14, 2019 at 4:40:51 pm

As far as I'm aware the answer is no.

There's a bit of a cheat around this.

You need a master text layer that'll be hidden. This is where you will type your text.

Then you'll have 2 text layers. Line 1 and Line 2. You then link the text to your master text layer and split them.

So
Line 1
text.sourceText.split('\r')[0];

Line 2
text.sourceText.split('\r')[1];

Then create two shape layers to fit around these two text layers.


Return to posts index

Deanna Keogh
Re: Expression that recognises 2 lines of text
on Mar 15, 2019 at 12:23:12 am

Thanks for your response!

So basically create 2 seperate layers of text that references to a text guide layer ?
And then have 2 seperate shape layers?

If that is the case I might as well just type straight into 2 seperate text layers and have the shape layer around them, without having the guide. Either way both of these solutions are fine. I suspected as much. I just didn't know if an expression existed where it would split the text and subsequently the shape layer it like I wanted.

Thanks so much!


Return to posts index


Tomas Bumbulevičius
Re: Expression that recognises 2 lines of text
on Mar 14, 2019 at 5:34:38 pm

This solution should solve your issue 100%. Apply your text to the layer visible at the center and make corrections in the 'control' null effects. This will place text from the bottom center and will grow upwards.

There is also a delay applied, so just remove it from shape layers if not needed.

If any questions occurs - just let me know, haven't used it for a while, but its solely my developed solution for such purposes. A bit too complex and slow, but it helped me a lot.

13203_textboxes1to4lines.aep.zip

Find out more:
After Effects Tutorials: motion design, expressions, scripting.


Return to posts index

Deanna Keogh
Re: Expression that recognises 2 lines of text
on Mar 15, 2019 at 12:10:42 am

Thanks so much for that.

I went to check out your project but unfortunately Im running an older AE and cant upgrade that this stage.
Any chance you could make that file backwards compatible please?
You're a gem!


Return to posts index

Tomas Bumbulevičius
Re: Expression that recognises 2 lines of text
on Mar 15, 2019 at 6:35:53 am

Deanna,

below is compatible since CC14. Hope that helps.

13206_textboxes1to4linescc14.zip

Find out more:
After Effects Tutorials: motion design, expressions, scripting.


Return to posts index


Scott McGee
Re: Expression that recognises 2 lines of text
on Mar 15, 2019 at 9:51:44 am

That's a cool project you have set up. I'm not even gonna pretend that I completely understand your expression for line breaking. I get the gist, but that is some serious expressioning haha.


Return to posts index

Tomas Bumbulevičius
Re: Expression that recognises 2 lines of text
on Mar 15, 2019 at 2:52:11 pm

Thanks Scott. Indeed, I am pretty sure there could be easier way of doing it, and more neat, but once I reached a point where it generated good enough results, I just added few extra checks 'here' and 'there' to avoid exceptions.

Find out more:
After Effects Tutorials: motion design, expressions, scripting.


Return to posts index

Ahmed Raad
Re: Expression that recognises 2 lines of text
on Dec 18, 2019 at 10:54:37 pm

Hi everyone

Tomas I've download the project that you put, but it did't working because I use windows, so if you could write the script that you did and I will be grateful to you.

sorry for my language i typing English with french grammar haha


Return to posts index

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