Calculate the Center of a Dynamic Connector

Started by snsisk, August 31, 2009, 06:46:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

snsisk


I have a need to calculate the center of a dynamic connector.  Does a way exist without using VB or parsing the geometry of the connector? 

Thanks,

Steve

wapperdude

#1
As long as your line is monotonic, that is, it doesn't loop back on itself, then the midpoint ought to be the sum of 1/2 the height + 1/2 the width.  See attached.  At least I believe this to be true.  Didn't rigorously check the math.

Wapperdude
Visio 2019 Pro

AndyW

How about using the controls.textposition in the dynamic connector. Visio does a fairly good job at keeping this centre of a dynamic connector, unless of course you reposition the text control point. If your lines don't have text you could create your own dynamic connector that didn't allow the text control point to be visible.
Live life with an open mind

Visio Guy

Do you want the midpoint of the line or the center of the shape, as in a "center of area" so to speak?

There is a LengthIU property available through automation, but that won't help you find the midpoint of a path. With automation, you can go further, however. Check out Paths, Path and Points in the developer reference. shp.Paths(n).Points. This allows you to get points and line-segments out of a shape's geometry.

And in the Visio 2010 technical preview, there is a new function: POINTALONGPATH. This sounds like it might do what you need, if you can wait.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

snsisk

Wow! Thanks folks.  It is great to have a place to go when you get stuck.

Chris's description of using the center of the line path is my goal.

Attached is a prototype of my objective shape, which happens to be a dynamic connector.  The text box on each end is offset from the end of the line depending on the text box width and an offset value. 

I am torn between using the line's integrated text or a separate text box.  If I use the a separate text box, expanding the number of text boxes will be much easier, I think.  I would like to place the center text box near the middle of the line path and let the user move the text box where ever they need because the center of the path isn't always the best place for the text.

The boxes are attached to the line by connection points.  I want to prevent the user from moving the text boxes at each endpoint.  Would using connection points or using the pin position of the text be a better approach?

Thanks again,

Steve


snsisk


Would using connection points or using the pin position of the text be a better approach?


Thanks,

Steve

Visio Guy

I forgot about an old trick: if you put a connection point on the connector, then Visio will try to maintain its position as a percentage of the connector length. So:

1. Draw a connector, simple, horizontal, 1 inch wide
2. Put a connection point at the middle, 0.5 inch along

When you resize the connector, add bends, connect to flowchart shapes, etc., the connection point will magically maintain a position 50% along the connector.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010