Connection Points

A

Ashok Kumar

Hi

I have serious problem to solve....

Of A shape placed, i need to add connection points
dynamically during the automation. Can Anyone help me in
creating new connection points dynamically

Any kind of help is appreciated.

Regards
Ashok Kumar
 
D

dani

Hi Ashok

all connection points of a shape are saved in the shapesheet. So if you
need to add additional connection points, you can access the
corresponding cell in the connection points section (if you don't have
any connection points yet, you probably need to add this section first.)

I assume you know how to access cells through automation. If not, just ask.

Daniel
 
A

Al Edlund

try this


' we needed an add connections routine for the drawing of the trace routes
' this is called by the following routine to add a standard set of
' connections to the rectangles used

Public Function funcAddConnectionPointToShape(vsoShape As Visio.Shape, _
strLocalRowName As String, _
strRowNameU As String, _
strLabelName As String, _
strConnectType As String, _
strX As String, _
strY As String, _
Optional strDirX As String, _
Optional strDirY As String, _
Optional blnAutoGen As Boolean) As Boolean

Dim vsoCell As Visio.Cell
Dim intRowIndex As Integer
Dim strCurrentTask As String ' for debug

On Error GoTo AddConnectionPt_Err

intRowIndex = vsoShape.AddNamedRow(visSectionConnectionPts, _
strLocalRowName, VisRowIndices.visRowConnectionPts)

If (strLocalRowName <> strRowNameU And _
Len(strRowNameU) > 0) Then
vsoCell.RowNameU = strRowNameU
End If

' Column 0: X
Set vsoCell = vsoShape.CellsSRC(visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visX)
vsoCell.Formula = strX

' Column 1: Y
Set vsoCell = vsoShape.CellsSRC(visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visY)
vsoCell.Formula = strY

' Column 2: direction x
Set vsoCell = vsoShape.CellsSRC(visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctDirX)
vsoCell.Formula = strDirX

' Column 3: direction y
Set vsoCell = vsoShape.CellsSRC(visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctDirY)
vsoCell.Formula = strDirY

' Column 4: type
Set vsoCell = vsoShape.CellsSRC(visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctType)
vsoCell.Formula = strConnectType

' Column 5: autogen
Set vsoCell = vsoShape.CellsSRC(visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctAutoGen)
vsoCell.ResultIU = blnAutoGen

funcAddConnectionPointToShape = True

Exit Function

AddConnectionPt_Err:

If Err > 0 Then
Debug.Print "Err in funcAddConnectionPointToShape " & Err & " " &
Err.Description & " " & strCurrentTask
funcAddConnectionPointToShape = False
End If

End Function



Public Sub subAddStandardConnections(visShape As Visio.Shape)

Dim visSection As Integer
Dim blnResult As Boolean

On Error GoTo AddStandardConnections_Err

visSection = visSectionConnectionPts
visShape.AddSection visSection

' since we have connections on all four sides we probably dont need a
middle
' blnResult = funcAddConnectionPointToShape(visShape, "Middle",
"Middle", "Middle", _
2, "Width * 0.5", "Height * 0.5", 0, False)

blnResult = funcAddConnectionPointToShape(visShape, "Left", "Left",
"Left", _
2, "0", "Height * 0.5", 0, False)

blnResult = funcAddConnectionPointToShape(visShape, "Right", "Right",
"Right", _
2, "Width", "Height * 0.5", 0, False)

blnResult = funcAddConnectionPointToShape(visShape, "Top", "Top", "Top",
_
2, "Width * 0.5", "Height", 0, False)

blnResult = funcAddConnectionPointToShape(visShape, "Bottom", "Bottom",
"Bottom", _
2, "Width * 0.5", "0", 0, False)

Exit Sub

AddStandardConnections_Err:

End Sub
 
A

Ashok

Hi Al

This Worked. Thanks a lot. I got another solution too..

Using GlueToPos command, I have given the x,y co-ordinates.

Even this solutions is usefull to me. Thanks a lot.

Regards
Ashok
-----Original Message-----
try this


' we needed an add connections routine for the drawing of the trace routes
' this is called by the following routine to add a standard set of
' connections to the rectangles used

Public Function funcAddConnectionPointToShape(vsoShape As Visio.Shape, _
strLocalRowName As String, _
strRowNameU As String, _
strLabelName As String, _
strConnectType As String, _
strX As String, _
strY As String, _
Optional strDirX As String, _
Optional strDirY As String, _
Optional blnAutoGen As Boolean) As Boolean

Dim vsoCell As Visio.Cell
Dim intRowIndex As Integer
Dim strCurrentTask As String ' for debug

On Error GoTo AddConnectionPt_Err

intRowIndex = vsoShape.AddNamedRow (visSectionConnectionPts, _
strLocalRowName, VisRowIndices.visRowConnectionPts)

If (strLocalRowName <> strRowNameU And _
Len(strRowNameU) > 0) Then
vsoCell.RowNameU = strRowNameU
End If

' Column 0: X
Set vsoCell = vsoShape.CellsSRC (visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visX)
vsoCell.Formula = strX

' Column 1: Y
Set vsoCell = vsoShape.CellsSRC (visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visY)
vsoCell.Formula = strY

' Column 2: direction x
Set vsoCell = vsoShape.CellsSRC (visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctDirX)
vsoCell.Formula = strDirX

' Column 3: direction y
Set vsoCell = vsoShape.CellsSRC (visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctDirY)
vsoCell.Formula = strDirY

' Column 4: type
Set vsoCell = vsoShape.CellsSRC (visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctType)
vsoCell.Formula = strConnectType

' Column 5: autogen
Set vsoCell = vsoShape.CellsSRC (visSectionConnectionPts, _
visRowConnectionPts + intRowIndex, visCnnctAutoGen)
vsoCell.ResultIU = blnAutoGen

funcAddConnectionPointToShape = True

Exit Function

AddConnectionPt_Err:

If Err > 0 Then
Debug.Print "Err in funcAddConnectionPointToShape " & Err & " " &
Err.Description & " " & strCurrentTask
funcAddConnectionPointToShape = False
End If

End Function



Public Sub subAddStandardConnections(visShape As Visio.Shape)

Dim visSection As Integer
Dim blnResult As Boolean

On Error GoTo AddStandardConnections_Err

visSection = visSectionConnectionPts
visShape.AddSection visSection

' since we have connections on all four sides we probably dont need a
middle
' blnResult = funcAddConnectionPointToShape (visShape, "Middle",
"Middle", "Middle", _
2, "Width * 0.5", "Height * 0.5", 0, False)

blnResult = funcAddConnectionPointToShape (visShape, "Left", "Left",
"Left", _
2, "0", "Height * 0.5", 0, False)

blnResult = funcAddConnectionPointToShape (visShape, "Right", "Right",
"Right", _
2, "Width", "Height * 0.5", 0, False)

blnResult = funcAddConnectionPointToShape
(visShape, "Top", "Top", "Top",
 

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