Author Topic: How do I create a dynamic text and graphic shape?  (Read 3547 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 7
How do I create a dynamic text and graphic shape?
« on: October 08, 2008, 08:19:01 AM »
I am trying to create a dynamic text shape that has a small graphic bullet aligned to the right of the text.  What I would like to do is to be able to click in the text box, type the text, and have the bullet move as the text lengthens or shortens.  Any ideas of how I could do this?




  • Jr. Member
  • **
  • Posts: 18
Re: How do I create a dynamic text and graphic shape?
« Reply #1 on: November 08, 2008, 08:03:10 AM »
I know this sounds easy.  At first glimpse you think about just appending a bullet character to the end of a string and viola!  But if you are aligning text and graphics it can get a bit more complicated.  Here is something that should at least get you going.

First lets assume you have a Rectangle (called Sheet.1) and it is a group, containing a Bullet graphic (called Sheet.2).  The text is part of the rectangle.

The basic strategy will be to position the bullet shape based on the TxtPin position of the rectangle plus the textwidth /2.  We divide by two, since the Text Pin is in the middle of the text (for centered text).  If you change the justification of teh text in your shape you will probably have to adjust the formula to match, but once you get a basic structure that works, you can always play with it.

Step 1:  Open the Rectangle's shapesheet, right-click, Insert Section and click "Text Transform".  I'm not sure if you have to do this, but I personally like to look at the values I depend on as they change when I am playing with new stuff.

Step 2: Open the bullets shapesheet.  In the PinY cell, place the following formula (or something similar)

Step 3: In the PinX type the following formula (or something similar)

=GUARD(Sheet.1!TxtPinX+TEXTWIDTH(Sheet.1!TheText,Sheet.1!Width)/2+2 pt)

This gets TxtPin.X from the rectangle and adds half the textwidth to get the pin position of the bullet.  I added 2pts for spacing as well.  If your bullet graphic is large, you will also need to offset by half the bullet's width, since it pins at its center.  In my example, the 2pts of space covers it.

You will also notice that teh second parameter to TEXTWIDTH() is passed as the width of the rectangle.  This is done assuming the text wraps at the edge of the rectangle.  Again, if your bullet graphic is large, you will need to account for its size in this calculation as well as in the way the text is wrapped in Sheet.1, otherwise the bullet will extend past the edge of the rectangle.

But this is only the simple case.  In this example, the bullet will eventually find itself outside the bounding rectangle, but that can be solved by adjusting the way that the text is wrapped in the rectangle itself, adjusting for the size of teh bullet (assuming that is known)


Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2948
    • Paul Herber's website
Re: How do I create a dynamic text and graphic shape?
« Reply #2 on: November 08, 2008, 12:17:46 PM »
Can this not be done with the standard text block?
At menu Format -> Text
just set the bullet type and then in the Paragraph section choose Right-to-Left
I can see that this may be too simple for some purposes.

Electronic and Electrical engineering, business and software stencils and applications for Visio -