Inward vs Outward connector isssues

E

epatrizi

Using the code below, I am inspecting the connection information in my
drawing. I have various custom shapes connected using dynamic
connectors. Some of the shapes have inward connection points and some
of the shapes have outward connection points. The dynamic connectors
seem to only be able to identify the shapes that it is connected to by
an inward connection point. The dynamic connector cannot seem to
identify the shape associated with the outward connection point.
Changing the outward connection point to inward fixes the problem but I
do not understand. You should see two entries for each dynamic
connector in the output at the bottom, one for each shape it connects.

Thx


Public Sub ToSheet_Example()

Dim vsoShapes As Visio.Shapes
Dim vsoShape As Visio.Shape
Dim vsoConnectTo As Visio.Shape
Dim vsoConnects As Visio.Connects
Dim vsoConnect As Visio.Connect
Dim intCurrentShapeIndex As Integer
Dim intCounter As Integer
Set vsoShapes = ActivePage.Shapes

'For each shape on the page, get its connections.
For intCurrentShapeIndex = 1 To vsoShapes.Count

Set vsoShape = vsoShapes(intCurrentShapeIndex)
Set vsoConnects = vsoShape.Connects

'Debug.Print vsoShape.Name;

'For each connection, get the shape it connects to.
For intCounter = 1 To vsoConnects.Count

Set vsoConnect = vsoConnects(intCounter)
Set vsoConnectTo = vsoConnect.ToSheet

'Print the name of the shape the
'Connect object connects to.
Debug.Print vsoShape.Name; "->"; vsoConnectTo.Name

Next intCounter

Next intCurrentShapeIndex

End Sub

Output:

Dynamic connector->Sheet.219
Dynamic connector.259->Sheet.219
Dynamic connector.260->Sheet.219
Dynamic connector.261->Sheet.219
Dynamic connector.262->OR-24
Dynamic connector.262->DO
Dynamic connector.276->AND-12
Dynamic connector.276->DO.269
Dynamic connector.284->Dynamic connector.262
Dynamic connector.284->Sheet.266
 
C

Chris Roth [ Visio MVP ]

I'm not seeing this behavior in Visio 2003. Try isolating the test first.

Draw two boxes with connection points.
Connect them at the connection points.
Select the connector.
Run this snippet:

' Select a connector that is connected to two boxes.
Sub SelectedConnectorDump()
Dim shp As Visio.Shape
Set shp = Visio.ActiveWindow.Selection(1)
Debug.Print shp.Connects.Count ' it better be 2!
Debug.Print shp.Connects(1).ToSheet
Debug.Print shp.Connects(2).ToSheet
End Sub

--

Hope this helps,

Chris Roth
Visio MVP
 
A

Al Edlund

I use something like this to get the names of the connected shapes
(obviously visConnect is the connection) in vb.net

Al

visShapeFrom = visConnect.FromSheet

if visShapeFrom.Connects.Count = 2 Then

strFromCell = visShapeFrom.Connects.Item(1).ToCell.Shape.Name.ToString

strToCell = visShapeFrom.Connects.Item(2).ToCell.Shape.Name.ToString

end if
 
E

epatrizi

I tried your example and had the same problem I described. Did you
change one of your connections points to outward?

I created a new drawing, added two boxes, added one connection point to
each box, made one connection point outward, and connected the two
boxes via the connection points. I selected the connection and ran
your code and got the following plus error message for nonexistant
second connection;

1
Sheet.2

I am running Visio 2003 with no updates.

Thanks,

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top