Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sourceRectAtTime + scale?

  • sourceRectAtTime + scale?

    Posted by Kieran Lefort on May 7, 2019 at 2:46 pm

    I have two layers: a single line text layer (“Name”) and a logo layer. The logo needs to stay the same distance from the right edge of the text, no matter how long the text is. I separated the x & y values of the Position of the logo and used the attached expression on the X Position and it works really well.

    (If you sensed a “however” coming, you’d be right and here it is…)

    HOWEVER the text layer needs to scale (controlled by a slider) to make sure longer names stay on the screen and the expression can’t account for the scale; it only reacts to the length of the text layer.

    What should I be adding to the expression so the logo stays the same distance from the from the right edge of the text, based on both the length of the and the scale?

    Simply adding the scale property doesn’t work, as AE sees it as an objective number and just adds the number.

    Thanks in advance.

    myLayer = thisComp.layer("Name");
    rectHeight = myLayer.sourceRectAtTime().height;
    rectWidth = myLayer.sourceRectAtTime().width;
    rectLeft = myLayer.sourceRectAtTime().left;
    rectTop = myLayer.sourceRectAtTime().top;
    xPos = myLayer.toComp(myLayer.anchorPoint)[0];
    x = rectLeft + xPos + rectWidth +50;

    Kieran Lefort replied 7 years, 1 month ago 3 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    May 7, 2019 at 3:44 pm

    Would setting your text as right aligned and making sure its anchorpoint is at 0,0, not work? No expressions needed

  • Griffin Englander

    May 7, 2019 at 11:46 pm

    Hey Kieran,

    You basically have to take the width and multiply it by your scale.

    Try this..

    myLayer = thisComp.layer("Name");
    rectHeight = myLayer.sourceRectAtTime().height;
    widthTemp = myLayer.sourceRectAtTime().width;
    rectWidth = (widthTemp*myLayer.transform.scale[0])/100;
    rectLeft = myLayer.sourceRectAtTime().left;
    rectTop = myLayer.sourceRectAtTime().top;
    xPos = myLayer.toComp(myLayer.anchorPoint)[0];
    x = rectLeft + xPos + rectWidth +50;

  • Kieran Lefort

    May 8, 2019 at 11:03 am

    And Griffin is the winner! That has solved my problem completely. Thank you so much.

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