I haven't found an answer to this anywhere. I am not sure if it is even possible.
I need to know how to center the anchor point of a single shape within a shape layer.
I am trying to rotate a couple of shapes within a single shape layer, but I cannot figure out how to get their anchor points centered. I know how to do it for the entire layer, but not for the contents within the layer.
Copy link to clipboard
You can do it manually by using the Pan Behind Tool.
With the shape selected activate the Pan Behind Tool (Y) and you can drag the anchor point of the shape wherever you like.
You could also open the Transform properties of the shape (it will say Transform: Shape name) and reset Anchor Point to 0, 0. But then you will proably have to adjust the shapes position when it shifts.
Is there a way to get the anchor point to snap to the exact middle of the shape?
Unfortunately I don't know a way of snapping the Anchor Point to the middle automatically while dragging it. Every snapping option I am familiar with in AE works at the layer level.
Resetting the anchor point back to 0, 0 in the shape layer transform would do it but it will also shift the shape position.
Now that I think of it, it might be possible with an expression to compensate for the shape position.
Copy link to clipboard
Parametric shapes are easy. Press the U key twice and reset the Contents/Rectangle/Transform Rectangle property to 0,0.
Paths are a different problem. If you reset the anchor point, the layer will move because the position will not automatically change like it does when using the "y" Pan Behind tool. You can use an expression to center the anchor point on any shape layer by using sourceRectAtTime(). Left will give you the left edge, and the width will provide you with the width, so half the width + the left will give you the center. Top will give you the distance from the layer's anchor point, and height will give you the height.
Apply this expression to shape layers Anchor Point:
ref = sourceRectAtTime(); w = ref.width/2; h = ref.height/2; l = ref.left; t = ref.top; [w + l, h + t]
That will center any path or parametric shape on the Shape layer's Anchor Point. If you have more than one shape on the layer, it will center the entire group. Only the Anchor Point will change, and the shape layer contents will be repositioned.
Unfortunately, sourceRectAtTime() does not take stroke width into account. As long as you have a closed path, the anchor point will be in the center of the shape, but if you have a C-shaped or U-shaped path, the anchor point will be off by half the stroke width.
You can use a similar approach with slightly different modifications to the expression to position the Shape Transform anchor point of a shape in the Contents section of a Shape layer so you can scale, rotate or skew from any corner or the middle of any side. I use this expression all the time. This is the one I have stored as an animation preset. It requires adding a Dropdown Menu Control and naming it Anchor Point Control, and adding nine menu items. It will work on any layer.
ref = sourceRectAtTime(); w = ref.width; h = ref.height; l = ref.left; t = ref.top; ctrl = effect("Anchor Point Control")("Menu"); if (ctrl == 1) [l + w / 2, t + h / 2]; else if (ctrl == 2) [l, t]; else if (ctrl == 3) [l + w / 2, t]; else if (ctrl == 4) [l + w, t]; else if (ctrl == 5) [l + w, t + h / 2]; else if (ctrl == 6) [l + w, t + h]; else if (ctrl == 7) [l + w / 2, t + h]; else if (ctrl == 8) [l, t + h]; else if (ctrl == 9) [l, t + h / 2]
I use it often. It is probably one of my top 10 Animation Presets.