ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

"Glue" a layer to the end of another layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Asaf Lazarovich
"Glue" a layer to the end of another layer
on Apr 26, 2018 at 9:16:11 am

Hi there, I have a text layer that contains a person's name and after that, a comp with a graphical punctuation mark (the punctuation mark cannot be a part of the text in this case), the punctuation mark always needs to come after the persons name, but the names changes in length (about a 1,000 name variations)
Is there a good way to "glue" the punctuation mark comp so it always sticks to the end of the text layer? keep in mind that the text layer doesn't move in position at all, it just changes in length.
thank you!


Return to posts index

Quest Rogers
Re: "Glue" a layer to the end of another layer
on Apr 26, 2018 at 8:09:23 pm

Is your exclamation point a shape layer?

You should be able to do this with sourceRectAtTime. If you put the expression below on the Position node on the shape layer's path in the Shape's Contents. Not the position node on the layer itself. The (-your number) at the end should be the pixel measurement of your text layer's width. If you right click on scale of any layer, select "Edit Value" then change the measurement to pixels you can find out how wide you layer is in pixels.

You can also put this in the position node of your layer then change the x and y values to what you need. For both cases the sourceRectAtTime will automatically move your exclamation point as the text layer changes length.

Hope this helps.

//Put this one on the shape layer's Position node under that shapes Contents.
x=thisComp.layer("text layer").sourceRectAtTime(time,false).width-your number;
y= your number;
[x,y]

//Put this one on the layer's position node and change the x and y as needed.

x=thisComp.layer("text").sourceRectAtTime(time,false).width+135;
y= 310;
[x,y]


Return to posts index

Asaf Lazarovich
Re: "Glue" a layer to the end of another layer
on Apr 29, 2018 at 7:31:55 am

Hi, sorry for the late response and thanks for answering
it works well, but there is a minor issue - the longer the text I write, the further the shape layer gets from the text
for example if the text is short like "mike" than it looks like this: mike!
but if the text is long like "alejandro" it looks like this: "alejandro !"
is there a fix for that?
thanks again!


Return to posts index


Quest Rogers
Re: "Glue" a layer to the end of another layer
on Apr 30, 2018 at 2:57:00 pm

No problem. I'm glad it's helping. I think your anchor point might be misaligned because I don't have that issue. Make sure your anchor point on the "exclamation point" is aligned on the bottom left of it's bounding box. I'd also set the anchor point of your text layer on the bottom left as well. Once you do this add the expression not before. Sorry I forgot to mention this before. This should fix the spacing issue. But let me know if it doesn't.

I like to use RepositionAnchorPoint for accurately changing it.
https://aescripts.com/repositionanchorpoint/


Return to posts index

Quest Rogers
Re: "Glue" a layer to the end of another layer
on Apr 30, 2018 at 3:56:44 pm

One more thing. Make sure your text is left aligned in the character panel too. Then make sure it's anchor point is aligned on the bottom left of the text layer bounding box.


Return to posts index

Asaf Lazarovich
Re: "Glue" a layer to the end of another layer
on May 1, 2018 at 6:49:17 am

Thanks guys, everything works now as it should


Return to posts index


Kevin Camp
Re: "Glue" a layer to the end of another layer
on Apr 30, 2018 at 6:39:47 pm

I might have missed something, but if the exclamation mark is the same font as the rest of the text, you could simply use this expression on the source text property of the name layer:

value + "!"

anything you type in the text layer will now have an ! at the end of it.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Kevin Camp
Re: "Glue" a layer to the end of another layer
on Apr 30, 2018 at 11:04:49 pm

Doh! you clearly stated that it could not be a part of the text.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

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