Author Topic: Connectivity Reporting  (Read 387 times)

0 Members and 1 Guest are viewing this topic.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3645
  • Ideas Visio-lized into solutions
Connectivity Reporting
« on: September 09, 2019, 02:33:29 PM »
Decided to see if there was a simpler way to find connectivity using custom code.  Yes... and no.
The code below is much simpler than previous versions, but, it doesn't always get the directionality correct.  Specifically, when a connector is glued to another connector, there can be misinformation.  But, on the other hand, it does seem to catch all of the connections.  Even those that are floating or only have one end connected.

So, for what it's worth, here's the code:  (note, output is immediate window, debug.print)
Code: [Select]
Public Sub GetGluedShapes()
'Use Shape.GluedShapes to get the shapes that are glued to a shape
    Dim shp As Visio.Shape
    Dim shpIDs() As Long
    Dim i As Integer

    Debug.Print "GluedShapes"
    For Each shp In ActivePage.Shapes
        If shp.OneD Then
            Debug.Print shp.Name
       
        shpIDs = shp.GluedShapes(visGluedShapesIncoming1D, "")
        For i = 0 To UBound(shpIDs)
            Debug.Print "Incoming 1D shapes"
            Debug.Print ActivePage.Shapes.ItemFromID(shpIDs(i)).Name
        Next
   
        shpIDs = shp.GluedShapes(visGluedShapesOutgoing1D, "")
        For i = 0 To UBound(shpIDs)
            Debug.Print "Outgoing 1D shapes"
            Debug.Print ActivePage.Shapes.ItemFromID(shpIDs(i)).Name
        Next
   
        shpIDs = shp.GluedShapes(visGluedShapesIncoming2D, "")
        For i = 0 To UBound(shpIDs)
            Debug.Print "Incoming 2D shapes"
            Debug.Print ActivePage.Shapes.ItemFromID(shpIDs(i)).Name
        Next
   
        shpIDs = shp.GluedShapes(visGluedShapesOutgoing2D, "")
        For i = 0 To UBound(shpIDs)
            Debug.Print "Outgoing 2D shapes"
            Debug.Print ActivePage.Shapes.ItemFromID(shpIDs(i)).Name
        Next
        End If
        Debug.Print ""
    Next
End Sub
« Last Edit: September 17, 2019, 07:04:22 PM by wapperdude »
Visio 2019 Pro

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3645
  • Ideas Visio-lized into solutions
Re: Connectivity Reporting
« Reply #1 on: September 17, 2019, 07:06:08 PM »
Updated file/code.
Visio 2019 Pro