Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Center anchor point of a layer to the centre of composition extend script

  • Center anchor point of a layer to the centre of composition extend script

    Posted by Avinash Ramanath on July 16, 2020 at 4:55 am

    I want to Center anchor point of a layer to the center of composition so that wehn I scale up, it scales from the center of the comp and not from the center of the layer. Thanks

    Filip Vandueren replied 4 years, 4 months ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    July 16, 2020 at 9:35 pm

    I’m a bit rusty, but I think that layerSpace transforms were not directly accessible in an extendscript, the way they are in expressions.

    the workaround:
    create a Null, apply an expression to it,
    read the result of the expression and then set that as the anchorPoint.
    (then throw away the null)

    The expression would be:

    thisComp.layer("center this").fromComp([thisComp.width,thisComp.height]/2);

    –> layer “center this” would be the target

    after you apply that value to your “center this” Layer,
    it would of course also need to positioned in the center of your Comp.

    Here’s an expression way to do that, because just setting it to [thisComp.width,thisComp.height]/2; would be wrong if the layer is parented.

    if (hasParent) {
    parent.fromComp([thisComp.width,thisComp.height]/2)
    } else {
    [thisComp.width,thisComp.height]/2;
    }

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