FORUMS: list search recent posts

Trim text layer based on character count

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Bryce Stewart
Trim text layer based on character count
on Mar 22, 2017 at 3:59:16 pm

Hi, I have built an automated project file that does many things I never thought AE was capable of until recently. Since I've gotten this far I figured I'd try to out due myself by adding some features I didn't initially think of. One of those is a way to tell AE to trim a text layer a specific length based on how many characters are used in the text layer. Is the possible through expressions? I've found a way to get the character count for the specific text layer. Now I just need to figure out if I can use that data to trim the layer somehow. Cheers


Return to posts index

Dan Ebberts
Re: Trim text layer based on character count
on Mar 22, 2017 at 5:37:36 pm

If you wanted to limit a text string to 10 characters, for example, you could do this:

txt = value;
maxChars = 10;
txt.substr(0,maxChars)

Dan



Return to posts index

Bryce Stewart
Re: Trim text layer based on character count
on Mar 22, 2017 at 6:36:09 pm

Dan, Thank you for the response. Funny enough I just threw a tip in on your website before you replied knowing you'd more than likely be the one replying based on reading this forum. You are a true share'r of knowledge. First and foremost, thank you for the time and energy you put into gaining this knowledge. Everyone else if your reading this, remember to support those who support you.

What I'm doing is importing text data into my project that auto fills out the text layer for me based off of a spreadsheet. This is being done with Templator on AE Scripts and then with some of my own hacked together expressions to do more of what I'm looking for. My challenge is to have the text layer being propogated with characters whether it be 30 characters or 60 to trim the layer based on the character count. Basically I know roughly how long it takes to read X amount of characters so I'd like the text layer to auto trim based on the text length and time it would take to read.

Does this explanation help you to see what I'm attempting to do?


Return to posts index


Dan Ebberts
Re: Trim text layer based on character count
on Mar 22, 2017 at 6:49:02 pm

I guess I'm not sure what you mean by "trim". Maybe an example would help.

Dan



Return to posts index

Bryce Stewart
Re: Trim text layer based on character count
on Mar 22, 2017 at 7:12:25 pm

If I have a composition and I create a text layer it will make the layer span the entire composition. For this example lets say the comp is 30 sec. and the text layer ive created is 30 sec. The amount of text I typed out (lets say 12 characters) in the text layer requires 10 seconds of on screen time to read so I can manually drag that text layer to the 10sec from the 30 sec mark but would rather the text layer know there are 12 characters and that 12 characters takes 10 sec to read so it trims my 30 sec text layer to 10sec. If i added 24 characters i would need it trimmed to be 20 sec long and not 30 sec.


Return to posts index

Dan Ebberts
Re: Trim text layer based on character count
on Mar 22, 2017 at 7:22:43 pm

You can't actually trim a layer with an expression (you'd need a script for that), but you could add an opacity expression like this:

charPerSec = 1.2;
dur = text.sourceText.length/charPerSec;
if (time > dur) 0 else 100


Dan



Return to posts index


Bryce Stewart
Re: Trim text layer based on character count
on Mar 22, 2017 at 8:22:37 pm

I think I can make this work. You helped me. Thank you.

Bryce


Return to posts index

Bryce Stewart
Re: Trim text layer based on character count
on Mar 22, 2017 at 8:33:54 pm

Instead of having it change from 0 else 100 can it fade? Something like the below code which I haven't got working yet

charPerSec = 1.2;
dur = text.sourceText.length/charPerSec;
if (time > dur) {transform.opacity;} else {( (this_layer.out_point-time)/0.5) * transform.opacity;}


Return to posts index

Dan Ebberts
Re: Trim text layer based on character count
on Mar 22, 2017 at 8:36:34 pm

How long is the fade, when does it happen, and what does it fade from/to?

Dan



Return to posts index


Bryce Stewart
Re: Trim text layer based on character count
on Mar 22, 2017 at 9:28:41 pm

The fade would start at the point the current opacity change happens. When time > dur. The other issue im encountering with this is that depending on the amount of characters the time is too long or too short.


Return to posts index

Dan Ebberts
Re: Trim text layer based on character count
on Mar 22, 2017 at 9:50:08 pm

You could try this:

charPerSec = 1.2;
fadeDur = .5;
dur = text.sourceText.length/charPerSec;
linear(time,dur,dur+fadeDur,100,0)

but it won't help with your duration issue. You have to define a relationship between the number of characters and the duration that is apparently more complex than just 1.2 characters per second.

Dan



Return to posts index

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