Finding & Highlighting Connected Shapes

Started by wapperdude, August 08, 2014, 05:57:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wapperdude

This post is derived from a previous post.  I felt that a more universal version of a proposed solution ought to be in its own topic. 

Basically, the goal was to select a shape on a drawing, go thru all of its connections collection, highlighting each that's connected to it and also the shapes glued to the other end of the connecting shape.  Plus, elevate the connectors/lines to the top of the z-order.  Again, thanks to Yacine for helping with the syntax structure of the code. 

At the risk of a "Duh, of course!" admission, it took me awhile for the light bulb to go on.  That's the way it is with me and programming lingo.  The connections collection can be any shape, 1D or 2D, as long as part of it is glued to something else.  Actually, the connections members are, more accurately, the glued points.  For example, a dynamic connector, both ends glued, counts as two members of connections collection.  But, if only one end glued, then, it contributes just one member.  If it's just floating, not connected to anything, then, it's not part of the collections membership.  Exclusive club!

For a 2D shape glued to another 2D shape, it is possible that the selected shape is glued "to" the other shape.  But if you select the "other" shape, it is glued "from" the previous shape.  That is, 2D shapes need to be examined for both "to and from" cases.  However, Dynamic Connectors, and I believe ordinary line shapes, only glue to other shapes.  Thus, to catch 1D members of a shape's connections collection, it is only necessary to look at "from" type connections.  (An additional scenario, I guess, is if either a dynamic connector or a line shape were selected, then, it would be necessary to check the "to" case.  Did not allow for such a scenario.)

So, the attached file, presumably, catches all of the different scenarios.  The selected shape will become green.  The highlighted shapes become blue.  In addition, the highlighted connectors / lines are elevated to the top of the z-order.

Enjoy!

Wapperdude
Visio 2019 Pro

wapperdude

OK.  Even more universal!    :o

If either a connector or line shape has something glued to it, then, it will have a "to" case.  The file has been updated to include some additional scenarios.  The code is less restrictive in its analysis.  So, I think it is now universal.   ::)   ???

Wapperdude
Visio 2019 Pro

Yacine

Good job! But where's my non-modal dialog??? (see previous post)
Yacine

wapperdude

 ;D

It was in the back of my mind...couldn't decide best approach.
    1. The non-modal approach...
    2. An all-in-one where the code gives user the option to either highlight or de-highlight...very simple additional code.

But, the idea of this post was really to just demonstrate the code that is needed to do the search and identify.  Sort of a launching place.  With a little more effort, it's possible to grab the shape names, the connector end points, what shape is connected to the end point, and even the connection type, e.g., a specific connection point row of the shape.  Perhaps send that info to a listbox or into some report.

Some of that might happen, but it would take additional requests...because I know you're fully capable on your own!   ;)

Cheers,
Wapperdude
Visio 2019 Pro

wapperdude

#4
Re-worked the code.  It now generates a listbox detailing the connectivity of the selected shape.
No Excel option.

...and still no default reset.  Focus is more on getting the info.
Visio 2019 Pro

wapperdude

Updated version:  improved code, does both listbox or Excel.  Still requires manual code change to switch from one to the other.  Presently set for Excel.

You can select either 1D or 2D shape to get the list of conectivities.

Wapperdude
Visio 2019 Pro