I spend a fair amount of my time centering text within shapes. I have a script that will center text quickly. (The script reads the name of the object (e.g. 123) and places and 'centers' the text within that object.)
However, it only works on fairly normal objects. Circles, squares, rectangles, ect all work great.
The problem comes when I need to align a vast amount of text over an equally vast amount of objects that aren't regular shapes. Quickly. Current method is to individually center each text over each object.
Is there a script, or an algorithm, or a plugin, or a fast way to accomplish this?
I have to do this thousands of times a day. I have tricks, of locking layers other than text and quickly lining up rows and such, but often there are huge amounts that simply have to be done one by one.
I'm sure there's a smart person with the answer (not me). But I am curious, are these shapes all unique or do they repeat? Are they named related to their shape? If the name relates to the shape the name could be used to help automate the process.
I imagine the answer relates to this fun video:
Most are unique, but very similar in size/dimension.
They are not named related to their shape, each has a unique number associated with it that has no relation to it's shape.
This could be a case for one of those machine learning algorithms. Wonder if they have something along these lines out there.
That's what i'm hoping for! Not having any luck finding anything out there though
In each of the cases shown, the path can be seen as an assembly of constituent parts, with the text centred within one of them.
Maybe you can use that, or one of our scripter friends.
In the first one, it is simply the larger bottom rectangle, so horizontally the centre is in the middle of the whole thing, and vertically it is determined by the height of the bottom part. Done by hand, you can ClickDrag with the Rectangle Tool between opposite corners of the bottom part, and centre the text within the new rectangle.
In the second one, it is the rectangle that could be seen as the intersection of two overlapping rectangles, so the centre is determined by the height of the horizontal rectangle and the width of the vertical rectangle. Done by hand, you can ClickDrag with the Rectangle Tool between the lower left corner and the inner corner where the top right sides of the constituent rectangles meet, and centre the text within the new rectangle.
I think the main issue is that the definition of "centres" is a human assessment and decision in this case.
At least for me it is rather hard to imagine that it can be done programmatically and automatically in Illustrator, such that it may include all possible shapes (not even thinking about different rotations).
This is great! Thank you!
It doesn't quite get the visual center, but it's far closer than anything else I've found.
Maybe I can modify it to adjust closer to a visual center.
I'm afraid that this script – according to the initial request – won't help in this case either, femkeblanco.
Don't you think so?
The script femkblanco linked is actually not bad, and I might be able to incorporate the math into my current script.
In this example, the 123 is where my current script places the text, and the circle is where the centroid script places the 'center'. So it's not perfect, but it might reduce the number of text labels I have to adjust.
Certainly I do not claim that it is a "bad" script. In fact, it is a very good script.
But it does not nearly do what you are actually looking for and may fail more often than not (at least when considering the endless variations of "irregular" geometry).
That's all I was going to say.