Author Topic: get name of item connector is connected to  (Read 260 times)

0 Members and 1 Guest are viewing this topic.

perry59

  • Full Member
  • ***
  • Posts: 208
get name of item connector is connected to
« on: February 23, 2020, 05:00:54 PM »
I know that this has been discussed before, so please pardon the repeat.
As the title says, I want to get the name of an item that a connector is connected to, BUT I want to do strictly within the shapesheet. I know it can be done via a macro, but I don't want macro's in my shapes. Previously it was said that this is not possible, but that discussion is several years old, perhaps things have changed?

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3794
  • Ideas Visio-lized into solutions
Re: get name of item connector is connected to
« Reply #1 on: February 23, 2020, 08:16:30 PM »
Nope.  Still no shapesheet function to do that.
Visio 2019 Pro

perry59

  • Full Member
  • ***
  • Posts: 208
Re: get name of item connector is connected to
« Reply #2 on: February 23, 2020, 09:00:59 PM »
I thought so, bummer!

vojo

  • Hero Member
  • *****
  • Posts: 1475
Re: get name of item connector is connected to
« Reply #3 on: February 23, 2020, 10:51:26 PM »
in general, shapes are not aware of other shapes around or attached to.
I believe the best you can do is to compare pinx and piny of the connector to the pinx and piny + offsets of the connection point.
if equal, then that connector is attached to connection point Q.

The generalized case would have lots of tedious math...ao I would not try do that.

OldSchool1948

  • Jr. Member
  • **
  • Posts: 63
Re: get name of item connector is connected to
« Reply #4 on: March 24, 2020, 12:10:33 PM »
I use a subroutine stored in a module that uses the GluedShapes method as illustrated in the below code snippets to return the Shape IDs for incoming and outgoing 2D shapes on a page, and then parses though them

Code
 
Set vsoPage = thisDocument.Pages

'// Get all shapes on that page
Dim vsoSelection As Visio.Selection
Set vsoSelection = vsoPage.CreateSelection(visSelTypeAll, _
                                visSelModeSkipSuper, vsoPage)

For i = 1 to vsoSelection.Count

     If isConnector(Shape) = true then   ' A custom function that identifies connectors shapes

         Dim vsoConnector as Visio.Shape
         Set vsoConnector = vsoSelection(i)

         '// Grab the Shape.IDs for all Incoming & Outgoing glued shapes
         Dim srcArrIDs() As Long
         srcArrIDs = vsoConnector.GluedShapes(visGluedShapesIncoming2D, "")

         Dim dstArrIDs() As Long
         dstArrIDs = vsoConnector.GluedShapes(visGluedShapesOutgoing2D, "")

         '// Parse through Source Shapes
         For srcAryCntr = 0 To UBound(srcArrIDs)
       
              Dim srcShape As Visio.Shape
              Set srcShape = vsoPage.Shapes.ItemFromID(srcArrIDs(srcAryCntr))

         '// Parse through Source Shapes
         For dstAryCntr = 0 To UBound(dstArrIDs)

              Dim dstShape As Visio.Shape
              Set dstShape = vsoPage.Shapes.ItemFromID(dstArrIDs(dstAryCntr))