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.
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.
There is a shortcut to this, right click shape > Transform > Center anchor point or somthing like this text.
you can also change it's shortcut to quick apply
That doesn't actually work. Transform is a layer level command, not a shape level one.
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.
This script will do what you want: https://blob.pureandapplied.com.au/a-content-centric-model-of-the-universe/ (put it on KBAR)
Putting an expression on is not really time efficient and complicates things if you are doing it for work e.g. creating a simple 2 line crosshair on one layer would take you ages.
That's why you create animation presets. When you are familiar with expressions and animation presets, all you have to do is select and click. The advantage of a script is that it can create more than one layer. It took about 15 minutes to create an animation preset that creates crosshairs with a single Shape layer, centers the crosshairs over the Anchor Point of the layer below, and allows you to adjust the width, length, and color of the crosshairs as well as a gap with expression control sliders. It even allows you to add a circle.
If you want to try it, here it is:
Most of the work was just a simple copy and paste of a basic expression for shape position, then some duplicate contents in the shape layer. If you want to be efficient, take the time to learn expressions.
This seems like an awefully simple thing to want to do, but for some reason is impossible without needing lengthy expressions.