• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Center text in an irregular shape - script/plugin?

Explorer ,
Feb 24, 2021 Feb 24, 2021

Copy link to clipboard

Copied

Hello,

 

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.

joer74233125_0-1614202797102.png

joer74233125_1-1614203041938.png

 

 

 

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.

Thanks!

TOPICS
Draw and design , Scripting , Third party plugins , Tools , Type

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Feb 24, 2021 Feb 24, 2021

Copy link to clipboard

Copied

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:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 24, 2021 Feb 24, 2021

Copy link to clipboard

Copied

This could be a case for one of those machine learning algorithms. Wonder if they have something along these lines out there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

That's what i'm hoping for! Not having any luck finding anything out there though

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 24, 2021 Feb 24, 2021

Copy link to clipboard

Copied

If you do not expect the issue the post was facing using their referenced algorithm, it may work - check out this legendary post which may have useful information surrounding this topic. https://community.adobe.com/t5/illustrator/javascript-how-to-check-if-a-shape-is-inside-another-curv...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Joe,

 

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

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).

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

I'm afraid that this script – according to the initial request – won't help in this case either, femkeblanco.

 

Don't you think so?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

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.

joer74233125_0-1614278820286.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

LATEST

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines