Text Along a Connector’s Path in Microsoft Visio 2010
A feature lacking in Visio, like for-EVER, is the ability to align text along a connector’s path.
Now, Visio 2010′s new ShapeSheet functions and capabilities finally deliver.
Today we’ll show-off the cool new connector that I’ve developed for you, and get a very light technical explanation as to how it works!
In a previous post, I was re-creating (for fun!) a flowchart that I had seen in the Süddeutsche Zeitung.
In that flowchart, I needed to place connector-text along the actual line of the connector. Every time I adjusted the drawing, the angle of the connector changed, and I had to re-orient the text using the Text Block Tool.
You can see here how I am hastening the onset of arthritis with too much mousing:
Getting connector text to do this automatically is something I’ve wanted to implement for a long, long time. But the ShapeSheet couldn’t do it. I always needed to resort to code to get it to happen.
Today, however, I fired up my Visio 2010 beta and put some new features to work. The result is a connector that places text at the very end, rotated to match the angle of the last part of the connector.
No matter how many segments the connector has, what the terminal angle is, or the line-style, the text ends up in a reasonable position, and correctly aligned with the end:
Not bad, eh?
New ShapeSheet Capabilities Make it Possible!
Visio has added two new functions that I’ve used in two custom User-defined cells of the connector’s ShapeSheet. Take a gander:
User.angPathEnd = ANGLEALONGPATH( Geometry1.Path, 1 )
User.pntPathEnd = POINTALONGPATH( Geometry1.Path, 1 )
Not only do we have new functions in Visi0 2010, but we are able to refer to new types of objects. Up until now, we had to refer to ShapeSheet cells, and only ShapeSheet cells. But you can see that “Geometry1.Path” refers to a thing–a geometry section that is a group of cells. That’s new, and it’s pretty useful.
As you use an automatic connector in Visio, extra segments get added or removed from the connector. This has made it impossible to refer to the “last point” and “next-to-last point”, because ShapeSheet cells were being created and destroyed as the connector was reconfigured.
Now I can simply ask the ShapeSheet to tell me the angle along the path of “Geometry1.Path”, at 100% along the path’s lenght (that’s the “1″ you see in both functions)
Using similar syntax, I can ask for the end point too. The illustrated POINTALONGPATH function tells returns a Visio point-structure (combination of x- and y-values) for the point which is 100% of the way along Geometry1.Path.
This information was enough for me to relocated the shape’s text at the very end of the connector, offset and rotated correctly.
Getting the text to be aligned at the end of the connector was fun. But I thought; “Hmm. That control handle that you can use to move text on Visio’s default connectors is also pretty cool!”
So I added a right-click context menu action to allow you to choose.
Notice the new, context Action menus that feature the fly-out, cascading items! You can read about these on John Goldsmith’s Custom Context Menus.
Here’s another look at the variations:
Have fun with this new connector. Note that this file uses new features available only in Visio 2010. while the file will likely open in Visio 2007 or Visio 2003, the shape won’t work as advertised.
If you don’t have Visio 2010, you might investigate getting a copy of the beta: Visio 2010 Beta: Sign Up Now!