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

Finding the centre of text

SOLVED
TimSharp
Regular Member

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Finding the centre of text

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

Re: Finding the centre of text

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

Re: Finding the centre of text

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

Announcements