cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Finding the centre of text

TimSharp
12-Amethyst

Finding the centre of text

Is there a way of selecting text on an illustration and finding the centre of the text in a macro?

I can only find what seems to be the lower left load point (.text.startpoint), but I want to mirror text about it's centre.

ACCEPTED SOLUTION

Accepted Solutions

Haven't done this on a single element, my method was for the contents of a page, but you should be able to make use of some of it. Below is a snippet from that code. The main idea is that you have to apply object_info in order to get points of an object. With the snippet below you'll get all four points, you can then use basic math to determine center.

     Define Final_Top as Float

     Define Final_Bottom as Float

     Define Final_Right as Float

     Define Final_Left as Float

     Create object_info ActiveDoc.firstSelectedElement

     ActiveDoc.firstSelectedElement.info.view_context.type = "extent"

     Compare_Left = ActiveDoc.firstSelectedElement.info.view_context.rectangle.left

     Compare_Right = ActiveDoc.firstSelectedElement.info.view_context.rectangle.right

     Compare_Top = ActiveDoc.firstSelectedElement.info.view_context.rectangle.top

     Compare_Bottom = ActiveDoc.firstSelectedElement.info.view_context.rectangle.bottom

View solution in original post

2 REPLIES 2

Haven't done this on a single element, my method was for the contents of a page, but you should be able to make use of some of it. Below is a snippet from that code. The main idea is that you have to apply object_info in order to get points of an object. With the snippet below you'll get all four points, you can then use basic math to determine center.

     Define Final_Top as Float

     Define Final_Bottom as Float

     Define Final_Right as Float

     Define Final_Left as Float

     Create object_info ActiveDoc.firstSelectedElement

     ActiveDoc.firstSelectedElement.info.view_context.type = "extent"

     Compare_Left = ActiveDoc.firstSelectedElement.info.view_context.rectangle.left

     Compare_Right = ActiveDoc.firstSelectedElement.info.view_context.rectangle.right

     Compare_Top = ActiveDoc.firstSelectedElement.info.view_context.rectangle.top

     Compare_Bottom = ActiveDoc.firstSelectedElement.info.view_context.rectangle.bottom

Wow that was quick, thanks Trevor, I'll check it out early next week, looks promising.

Announcements

Top Tags