I got a surprise in one of my projects when I counted the shapes glued together using the Shape.GluedShapes(…) method … the sum of the filtered glued shapes just didn’t add up to the unfiltered count. So, I thought I should check the Shape.ConnectedShapes(…) method too … and there is a scenario where that has a similar result.
In the following diagram, I have different coloured squares with connection points of different types at the centre of each edge (as denoted by the connection type numbers), and one under a control point in the bottom left corner. I have glued the ends of coloured connector lines, statically (Red and Black) and dynamically (Green), and glued the Purple Square directly to the Orange Square. The Blue Square shape is glued to a connection point on the green dynamic connector.
I then ran some code to get the count of glued and connected shapes … and noticed some apparent discrepancies…
So, let’s look at the Green Dynamic Connector in the report above…
The green dynamic connector reports that it has 3 glued 2D shapes when using the following call:
Shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesAll2D, "")
However, the following two methods return 1 each:
Shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesIncoming2D, "")
Shape.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing2D, "")
So, that means that means there is one glued shape that is not either incoming or outgoing on the 1D shape … and that is the Blue Square shape which is glued to the connection point on the Green Dynamic Connector. Infact it is a member of the Shape.FromConnects collection but does not get found by the GluedShapes(…) method when filtered.
The Blue Square is apparently missing a 1D glued shape, which is the Green Dynamic Connector. It does appear in the Shape.Connects collection though.
Another surprise was the double connections between the Blue Square and Orange Square shapes! These two are glued with two InwardOutward (2) connection point types, which allows two 2D shapes to be glued together. The Angle cell references must be required to control the rotation of one shape with respect to the other.
I was a little confused, at first, about the two ConnectedShapes for the Orange Square too. It finds the Yellow Square and the Blue Square, but I had expected the Yellow Square, maybe twice, since it is at the end of two connectors. However, the Blue Square is reported in addition to the Yellow Square. Infact, when I unglued the Blue Square then ConnectedShapes(…) only reported the Yellow Square once.
So, my lesson from all this is not to trust the Shape.GluedShapes(…) and Shape.ConnectedShapes(…) methods when the structure of the diagram is a more complex than normal.
All of the data for the Shape.Connects and Shape.FromConnects collections comes from the Page.Connects collection. The Shape.GluedShapes(…) and Shape.ConnectedShapes(…) must also get most of its data from there, but also adds in the possibility of filtering by a category name that is in the User.msvShapeCaategories cell.
You can download this sample macro-enabled Visio document from here A review of connections.vsdm, and the VBA calls which simply output into the Immediate Window are:
- ListGlues()
- ListConnections()
- ListDetailedShapeConnects()
- ListDetailedPageConnects()
Related Posts
Pushing Data Visualizer in Visio beyond its limits
My last post was about some of the lessons learnt when trying to push Data Visualizer to its limits, but this one has some ways of overcoming these limitations. The main lesson learnt is that DV binds the shapes within the DV container shape, CFF Data Visualizer, and controls some of the ShapeSheet cells that…
Pushing Data Visualizer in Visio to the limits!
Regular readers of my blog will know that I like to use the Data Visualizer (DV) in Visio Plan 2, but I recently tried to help a user who really decided to push it to the limits. In this scenario, there were multiple connections, but with different labels, being created between the same flowchart shapes,…
What is the difference between a line and a [dynamic] connector in Visio?
Learn what the difference is between a line and a connector shape in Visio
Cyber Monday free Visio Checkers!
As it is Cyber Monday, I thought I would give away a compelling checkers board for Visio! In the UK, we call it Draughts, but the rules are the same… in my last post, I showed how to create a chess/checkers/draughts board, and in this one I add some checkers that can glue to the…
Update to multiSelect & tracing sub-shape connections in Visio
Most of my Visio diagrams have simple connections between shapes, and my previous post about connections used a flowchart as an example (see https://blog.bvisual.net/2016/08/09/understanding-visio-connections/ ). However, it has come to my attention that some Visio developers add connection points to sub-shapes of Visio group shapes, and then connect between the sub-shapes. This means that the…
Understanding Visio Connections
A reader recently asked if I could explain how to programmatically get the shapes connected to a shape in Visio. So, I thought I would have a go, because there are alternatives, depending upon which functions are used, and what parameters are passed to them. The following animated gif is rotating around the different types…
Leave a Reply