Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions parent layer vs position expression

  • parent layer vs position expression

  • Scott McGee

    August 14, 2018 at 10:25 am

    I’ve never tried this before and completely stumped on how to do this other than by parenting.

    I have a group of circles that rotate based on an anchor point, other than using a null with a delay and few other bits. I’ve animated my circles that then stop in this position.

    I want my text to sit on top and using 0 – thisComp.layer(x).rotation, to keep the text horizontally.

    no when I use a position expression it’s using position/anchorpoint, which I know why it’s doing that, but is there an expression that to get the actually position of the shape layer? So it’s like this.

    Otherwise I’ll just continue to use parenting.

  • Kalleheikki Kannisto

    August 14, 2018 at 1:32 pm

    Depending on what else is happening in your comp, this either works or it doesn’t…

    A few prereqs:
    1) The anchor point of the text layer is centered on the text layer and
    2) the original position of the text is at the anchor point of the shape layer,

    That being the original situation, the text layer position follows the rotation value of “Ellipse 1” in the shape layer with this:

    xd = thisComp.layer("Shape Layer 1").content("Ellipse 1").transform.position[0];
    yd = thisComp.layer("Shape Layer 1").content("Ellipse 1").transform.position[1];
    xd *= xd;
    yd *= yd;
    d = Math.sqrt(xd+yd);
    xpos = -d * Math.sin(degreesToRadians(thisComp.layer("Shape Layer 1").transform.rotation));
    ypos = d * Math.cos(degreesToRadians(thisComp.layer("Shape Layer 1").transform.rotation));
    value-[xpos, ypos]

    So, essentially, were adding the position transformation of the rotating Ellipse 1 to the position of the text layer.

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Scott McGee

    August 17, 2018 at 7:44 am

    Ooo, nearly worked.

    So it rotates based on the position perfectly, but is there anyway to get the text to anchor itself directly into the centre of the circle. That was my other problem.

    because I want to utilise the anchor in the centre of the comp for my circle to rotate. I couldn’t figure out how to get my text to sit in the circle as it places itself based on the position which it thinks is the centre of the comp. But that’s a cool trick for the rotation.

    As I’m still learning, what does this mean though?

    xd *= xd;
    yd *= yd;

    I understand the rest, but that I don’t.

  • Kalleheikki Kannisto

    August 18, 2018 at 8:24 am

    xd *= xd is shorthand for xd = xd * xd, in the same fashion as xd += 5 is shorthand for xd = xd + 5.

    Considering you need to rotate the text layer around its anchor point to keep it horizontal, you can’t move it in the center of the comp. I guess you could do it in reverse, calculating with sourceRectAtTime the rotation point for the text that is in the center of the text layer like the anchor point currently is. To me it seems like a more complicated method of achieving the same result.

    Since the text and the circles are on separate layers, I don’t know why this would be an issue. Just need to drag the text layer to the original position in the center of the circle first. But maybe you have other things going on in the animation which I don’t know of that make the situation more complicated.

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Scott McGee

    August 20, 2018 at 7:41 am

    No other things and that all makes sense. I’ll have a stab at it today and see how that does.

    Cheers for the help and advice.

  • Scott McGee

    September 3, 2018 at 9:13 pm


    I accidently came across this expression that does exactly what I want it to

    L = thisComp.layer(“Shape Layer 3”);
    r = L.sourceRectAtTime(time,false)
    L.toWorld([r.left + r.width/2, + r.height/2]);

Viewing 1 - 6 of 6 posts

Log in to reply.

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