Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Glue” a layer to the end of another layer

  • “Glue” a layer to the end of another layer

    Posted by Asaf Lazarovich on April 26, 2018 at 9:16 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!

    Asaf Lazarovich replied 8 years, 3 months ago 3 Members · 7 Replies
  • 7 Replies
  • Quest Rogers

    April 26, 2018 at 8:09 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]

  • Asaf Lazarovich

    April 29, 2018 at 7:31 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!

  • Quest Rogers

    April 30, 2018 at 2:57 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/

  • Quest Rogers

    April 30, 2018 at 3:56 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.

  • Kevin Camp

    April 30, 2018 at 6:39 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

  • Kevin Camp

    April 30, 2018 at 11:04 pm

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

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Asaf Lazarovich

    May 1, 2018 at 6:49 am

    Thanks guys, everything works now as it should

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