Author Topic: Who's your neighbor: connectors, gluing, spatialneighborhood  (Read 2678 times)

0 Members and 1 Guest are viewing this topic.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3975
  • Ideas Visio-lized into solutions
Who's your neighbor: connectors, gluing, spatialneighborhood
« on: September 09, 2014, 01: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
Visio 2019 Pro

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3975
  • Ideas Visio-lized into solutions
Re: Who's your neighbor: connectors, gluing, spatialneighborhood
« Reply #1 on: September 10, 2014, 12: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:
Code
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
« Last Edit: September 10, 2014, 12:28:12 AM by wapperdude »
Visio 2019 Pro

vojo

  • Hero Member
  • *****
  • Posts: 1557
Re: Who's your neighbor: connectors, gluing, spatialneighborhood
« Reply #2 on: September 10, 2014, 09:44:20 AM »
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.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3975
  • Ideas Visio-lized into solutions
Re: Who's your neighbor: connectors, gluing, spatialneighborhood
« Reply #3 on: September 10, 2014, 10:45:07 AM »
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
« Last Edit: September 10, 2014, 11:15:59 AM by wapperdude »
Visio 2019 Pro

doudou

  • Jr. Member
  • **
  • Posts: 26
Re: Who's your neighbor: connectors, gluing, spatialneighborhood
« Reply #4 on: September 10, 2014, 04:04:46 PM »
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:
Code
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

rezingg

  • Jr. Member
  • **
  • Posts: 16
Re: Who's your neighbor: connectors, gluing, spatialneighborhood
« Reply #5 on: January 06, 2021, 02: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.