VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to know the coordinates of a certa in alphabet in a word

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
167 Views, 7 Replies

how to know the coordinates of a certa in alphabet in a word

hi i have a column of words that share a certain alphabet, how to determine the coordinates of a certain alphabet so that i can Arrange the words in a line made by the alphabet thank you regards
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

I'm assuming you mean they share a single letter. I would probably use bounding boxes to break the words at the letter that is shared, and adjust the horizontal text positions based on these widths. For example: -- "shape" and "cactus" share "a". -- Use GetBoundingBox() to get widths of "shape" and "cactus" text objects. -- Change SHAPE's textstring to APE and store the original word in a variable. -- Change CACTUS's textstring to ACTUS and store the original word in a variable. -- Use GetBoundingBox() to get widths of APE and ACTUS text objects. -- Change the words back to their original values. -- The new Y-coord for the CACTUS text should be found by the following formula: (Y-coord of insert point of SHAPE) + (width of SHAPE) - (width of APE) + (width of CACTUS) - (width of ACTUS) If you have a column, just go down the list of words, using this method on each one to align it with the first word. This isn't tested, it's just how I would go about trying to do it. HTH, James
Message 3 of 8
Anonymous
in reply to: Anonymous

> -- The new Y-coord for the CACTUS text should be found by the following > formula: > (Y-coord of insert point of SHAPE) + (width of SHAPE) - (width of APE) + > (width of CACTUS) - (width of ACTUS) oops... both times, I meant to say "X-coord", not "Y-coord".
Message 4 of 8
Anonymous
in reply to: Anonymous

Thanks for your advice.i would like to try. thank you regards --------------------- "James Belshan" wrote in message news:40aa187b_1@newsprd01... > > -- The new Y-coord for the CACTUS text should be found by the following > > formula: > > (Y-coord of insert point of SHAPE) + (width of SHAPE) - (width of APE) + > > (width of CACTUS) - (width of ACTUS) > > oops... both times, I meant to say "X-coord", not "Y-coord". > >
Message 5 of 8
Anonymous
in reply to: Anonymous

> Thanks for your advice.i would like to try. > Good luck. Let us know if this approach works or does not work for you, or if you run into problems. James
Message 6 of 8
Anonymous
in reply to: Anonymous

hi, i tried ,and i partly succeeded. for i found that the widths of the bounding boxes are sometimes different though the len of two words are same.( i dont know why) (for exemple word1.36 bounding box width 411, word 2.56 bounding box width 487) thank you after all
Message 7 of 8
Anonymous
in reply to: Anonymous

youngman, If the font used by the text items is a "proportional" font, different letters can have different widths. So "1.36" can have a different width than "2.56" even though they have the same number of letters. The method I gave you should be able to handle this, because the bounding boxes are based on the actual font used by each text item. My VBA isn't working yet on my new computer, otherwise I would just try to try out a quick example. James
Message 8 of 8
Anonymous
in reply to: Anonymous

Thank you so much. i am too busy to have a complete try . thanks after all. best regards "James Belshan" wrote in message news:40ab6a2c_1@newsprd01... > youngman, > > If the font used by the text items is a "proportional" font, different > letters can have different widths. So "1.36" can have a different width > than "2.56" even though they have the same number of letters. The method I > gave you should be able to handle this, because the bounding boxes are based > on the actual font used by each text item. > > My VBA isn't working yet on my new computer, otherwise I would just try to > try out a quick example. > > James > > >

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost