Visio Guy

Visio Discussions => Programming & Code => Topic started by: wapperdude on September 09, 2014, 06:12:28 PM

Title: Who's your neighbor: connectors, gluing, spatialneighborhood
Post by: wapperdude on September 09, 2014, 06:12:28 PM
Another post on the topic of connectors and gluing and finding closest connection point.  This also originated in another post.  The attached file demonstrates how a bunch of connectors, not glued to any shape may easily be re-glued.  I've also incorporated two additional macros to establish a list of connectivity from previous developments.

Since it is quite possible that neither connector end may be glued, that prevents the use of the connects collection as a means of search.  Additionally, the spatialneighbors methods cannot be restricted to just end points.  Thus, a connector that may route near an unrelated 2D shape would be "passing thru the neighborhood".  But, the method does minimize the potential candidates, which then allows a methodical evaluation of connection point locations to see which may be within the desired spacing of either end of the connector.

The two other macros use either the Shapes.connects or Page.connects collections to generate a report showing connectivity after running the gluing macro.  These were kept distinct to allow easier code investigation.

Enjoy.

Wapperdude
Title: Re: Who's your neighbor: connectors, gluing, spatialneighborhood
Post by: wapperdude on September 10, 2014, 05:26:27 AM
Ooops...found minor error in the glue code.  In the "IF" statements for checking the location of connector end points vs 2D shape connection points, the equality should be <=, not the < as indicated.  This is only a problem for very small radius cases.

The two corrected code lines are:

If (Abs(xCon - xBeg) <= intTolerance) And (Abs(yCon - yBeg) <= intTolerance) Then                           


If (Abs(xCon - xEnd) <= intTolerance) And (Abs(yCon - yEnd) <= intTolerance) Then                           


In the attached file, error has been corrected.

Wapperdude
Title: Re: Who's your neighbor: connectors, gluing, spatialneighborhood
Post by: vojo on September 10, 2014, 02:44:20 PM
FWIW...I have always had problems with the spatialneighbor function in VBA.   For some reason, for me, it was a crude approximation:
I could find the "city" the shape is in....but got real confused if looking for the "street" the shape is at.
Title: Re: Who's your neighbor: connectors, gluing, spatialneighborhood
Post by: wapperdude on September 10, 2014, 03:45:07 PM
Yep!  Seems like it's one of those functions that ought to have great usefulness, but then you try to use it, and it's almost totally useless.  I couldn't agree with you more Vojo!

Ranks right there with SETATREF. 

Wapperdude
Title: Re: Who's your neighbor: connectors, gluing, spatialneighborhood
Post by: doudou on September 10, 2014, 09:04:46 PM
Quote from: wapperdude on September 10, 2014, 05:26:27 AM
Ooops...found minor error in the glue code.  In the "IF" statements for checking the location of connector end points vs 2D shape connection points, the equality should be <=, not the < as indicated.  This is only a problem for very small radius cases.

The two corrected code lines are:

If (Abs(xCon - xBeg) <= intTolerance) And (Abs(yCon - yBeg) <= intTolerance) Then                           


If (Abs(xCon - xEnd) <= intTolerance) And (Abs(yCon - yEnd) <= intTolerance) Then                           


In the attached file, error has been corrected.

Wapperdude

That is exactly what I did in my modification :). Great work on the other connectors stuff also. Cheers,

Jean
Title: Re: Who's your neighbor: connectors, gluing, spatialneighborhood
Post by: rezingg on January 06, 2021, 07:14:15 PM
Good start to a glue healing tool. I added the use of Shape.XYToPage() to make this also work for shapes that are rotated or mirrored.