ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Avinash Ramanath
Center anchor point of a layer to the centre of composition extend script
on Jul 16, 2020 at 4:55:44 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


Return to posts index

Filip Vandueren
Re: Center anchor point of a layer to the centre of composition extend script
on Jul 16, 2020 at 9:35:46 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;
}




Return to posts index

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