Site icon bVisual

Adding More Smartness to Visio Connectors

Whenever I have been asked why I like Visio so much, I have usually cited its ability to connect shapes together; its ability to link to data; and its programmability. Visio 2010 formally added a structured diagram concept and API, and the premium edition introduced diagram validation. So many different types of Visio diagrams require elements to be connected together correctly, and I often have to add a little extra into the connectors to make them smarter.

What is a connector?

A connector is a Visio shape that has 1-D behavior. The most used example is the Dynamic connector shape, which not only connects elements together, but can also re-route itself according to the layout and routing options selected for a page.

Verifying that a connector is actually connected

If you look at the ShapeSheet of a connector, you will see that the 1-D Endpoints section has formulas for the Begin and End X/Y co-ordinates. Additionally, there are special trigger formulas in the Glue Info section.

Note that the screenshots in this blog are from Visio 2010, where red is used to indicate a connection; however, Visio 2013 has changed this to a green display because too many people associate red with some sort of error.

If one end of a connector is disconnected, then you can see that the formulas in the 1-D Endpoints and Glue Info sections change:

However, if you look at the values of the Glue Info cells, you can see that a connected end has a value of 2, but a disconnected end has a value of 1 (or possibly 0 if it has never been connected).

Thus, you could use the values in the BegTrigger and EndTrigger cells to check if a connector is actually connected at either or both ends. The next decision is how you intend to visualise the result with just ShapeSheet formulas – line pattern, line arrow, line color, text or something else? If you allow users to vary the line format, then perhaps pattern, arrow and color should not be set with ShapeSheet formulas. Text on connectors could be used for some other purpose, so what’s left?

Well, I would suggest this could be a good use of Action Tags because they are only visible in Visio.

So, I made some amendments to the Dynamic connector master in my document:

First, I added a Fixed List (1) Type Shape Data row, Prop.ConnectorErrorDisplayMode, to its page with the Format =”None;Mouse Over;Shape Selected;Always”

I then added two Action Tags rows to the shape, one for the possible misconnection at the start of the line, and one for the end:

I set the DisplayMode formula to lookup its value from the Shape Data row that I created in the page of the master:

=LOOKUP(ThePage!Prop.ConnectorErrorDisplayMode,ThePage!Prop.ConnectorErrorDisplayMode.Format)-1

This formula will actually return the values 255,0,1 or 2, and I happily discovered that any value except 0,1 or 2 will render the action tag row invisible.

When the Dynamic connector is used in the diagram, then you can get a more visible display of any error connection errors:

I also included a formula in the Description cell of each Action Tags row so that it would appear as a screen tip in Visio:

By the way, Action Tags are always the same size, regardless of your zoom level so you can spot connection errors even when zoomed right out.

What is the flow direction?

In some types of diagram, it is important to get the flow direction correct, especially if Visio is to be used as the source of a data export to some other application.

The above screenshots were taken whilst a theme was applied, which provided the arrow at the end of each connector, however, if the user chooses to have no theme, then it is impossible to tell which way the connector is flowing:

So, I think it is useful to either preset the end arrow of your connector, or to use a theme which displays the flow direction. In any case, there is a Visio command, Reverse Ends, that can be added to your ribbon in order to provide the ability to easily switch a line flow direction.

Those of you who have been following my blog may have already worked out where I am going with this ….

Exit mobile version