Copy link to clipboard
Copied
Hi,
I'm running into a problem with anchor points for paragraph text in After Effects 14.2.1.34. When the text box for paragraph text is resized, the anchor point does not update, it just stays in the center of the initial text box. My paragraph panel was set to centered text, though I don't think that matters for the anchor point. After Effects continues to report the text position (Transform: Position) as the position of the anchor point.
To replicate this:
- Click the Horizontal Type Tool.
- Click on the canvas and drag the mouse to make a large box. (This will create "paragraph text" instead of "point text".)
- Type some text in the box. Click the Selection Tool to end text entry.
At this point you will have a text layer with a text box, and its anchor point is centered in the text box. Use Selection Tool, click the text and you can see handles around the text and the anchor point.
Use Horizontal Type Tool, click the text and you will see the text box (but not the anchor point).
- Now resize the text box (I made it much smaller). The anchor point stays in its original location, and is no longer centered in the text box.
The anchor point is reporting (0, 0) and the text is reporting its position as the position of the anchor point - which is not the text position any longer. This happens in the After Effects UI and from the plugin SDK.
Is there a way to find the actual text position in this circumstance? (From script or from the SDK). Or am I missing something that accounts for this offset between the text position and anchor point?
Related post: Getting a box text anchor point after resizing it
If you want to calculate the size of the active text you can use the sourceRectAtTime().height and width method...
Thanks Rick. sourceRectAtTime() is quite useful! It turns out that sourceRectAtTime().left and .top are just what I was looking for - they give the offset from the anchor point to the top-left corner of the text. And they do get updated when the text, text box, or anchor point changes.
It seems to take three values to calculate the (top-left) text position:
layer.transform.position -->
...Copy link to clipboard
Copied
Shoot me, because I so rarely use paragraph text, but I think that is normal and has always been this way for eons. At least the anchor point never adapts automatically to the text. It behaves like a shape layer in that regard. the coordinates being reported falsely could be a bug, though.
Mylenium
Copy link to clipboard
Copied
This is normal behavior on resizing any path shape and that is what a text box is. You can draw the initial text box anywhere in the screen and the anchor point will be in the center. Press the U key twice and you'll see only position because the Anchor Point is at the default 0,0 for a text layer. It has always been 0,0. Start typing anywhere, type as many lines as you want and when you finish the Anchor Point will always be at the left edge, center, or right edge of the first line of text, depending on the paragraph style you selected. The anchor Point will always be at the middle of any text box you have drawn.
Hold down the Ctrl/Cmnd key and just like a mask or a vector path it will resize from the center of the rectangle. The Ctrl/Cmnd key plus Shift will constrain proportions. The anchor point won't move and neither will the position. This is exactly the same behavior that happens when resizing masks. If you hold down Ctrl/Cmnd on a text layer and resize the box the anchor point will still be in the middle of the text box and the position won't change. If you do not hold down the modifier and you resize the text box then, just as in Illustrator, Photoshop when transforming, or any vector path in AE, the anchor point won't move. If you want to move it to the exact center of the new text box then just turn on snapping and use the Anchor Point tool.
If you want to calculate the size of the active text you can use the sourceRectAtTime().height and width method, but there is no expression that will give you the size of a text box, just the size of the text inside of the box. It might be a good feature request though. I can think of a bunch of times that retrieving he size of a text box would be handy.
Copy link to clipboard
Copied
If you want to calculate the size of the active text you can use the sourceRectAtTime().height and width method...
Thanks Rick. sourceRectAtTime() is quite useful! It turns out that sourceRectAtTime().left and .top are just what I was looking for - they give the offset from the anchor point to the top-left corner of the text. And they do get updated when the text, text box, or anchor point changes.
It seems to take three values to calculate the (top-left) text position:
layer.transform.position --> gives you coordinates of anchor point "origin" (center of initial text box)
layer.transform.anchorPoint --> offset of anchor point from its origin (using "pan behind (anchor point) tool" changes this)
layer.sourceRectAtTime().left & .top --> offset of text from adjusted anchor point (not displayed anywhere in UI!)
So the text position ends up being
position - anchorPoint + (sourceRect.left, sourceRect.top)
Copy link to clipboard
Copied
update the anchor point, sourceRectAtTime().left and top won't change, test on AE 2021 on mac.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now