Draw lines from shape to shape, without specifying the coordinates

S

Stigur

Hi,

I'm developing xml for Visio, outside Visio.

I need to draw lines between shapes. And this I can do. But the lines are
straight from shape to shape. They must run in straight runs up or down, with
90-degre bends.
Is there a way to ask Visio to do this, without having to calculate the
coordinates of the run, as this would be a quite complex and time-consuming
task.

Best regards,
Stigur
 
A

Al Edlund

I use something like this (vb.net) for a network drawing
Al
' connect two network nodes in the diagram using the dynamic

' connector from the basic flowchart stencil using a named

' connection on the nodes (i.e. port name)

Private Sub ConnectSiteNodeANodeB(ByVal strNodeA As String, _

ByVal strNodeAPort As String, _

ByVal strNodeB As String, _

ByVal strNodeBPort As String)

Dim objPageSheet As Visio.Shape

Dim objNodeA As Visio.Shape

Dim objNodeB As Visio.Shape

Dim objCell As Visio.Cell

Dim intObjects As Integer

Dim visApp As Visio.Application

Dim frmMain As frmAnchorMenu

' get the pointer to the anchor menu

frmMain = GetAnchorMenu()

' so that we can get the pointer to the active visio application

visApp = frmMain.ParentVisioApplication

Dim sbStencil As New StringBuilder

sbStencil.Append(frmMain.txtApplicationDataPath.Text)

sbStencil.Append(frmMain.txtTemplate_VSS.Text)

' so that we can get the pointer to the active visio application





Dim visPage As Visio.Page

Dim visMaster As Visio.Master

Dim objCable As Visio.Shape

Dim strTempName As String

Dim tmpShape As Visio.Shape

Try

visPage = visApp.ActivePage

For Each tmpShape In visPage.Shapes

With tmpShape

strTempName = tmpShape.NameU.ToString

If strTempName = strNodeA Then

objNodeA = tmpShape

End If

If strTempName = strNodeB Then

objNodeB = tmpShape

End If

End With

Next tmpShape

Dim visStencil As Visio.Document

visStencil = visApp.Documents.OpenEx( _

"Basic Flowchart Shapes (US units).vss", _

visOpenDocked)

visMaster = visStencil.Masters.ItemU( _

"Dynamic Connector")

objCable = visPage.Drop(visMaster, 8.5, 11)



objCell = objCable.Cells("LineWeight")

objCell.Formula = "0.5 pt"

objCell = objCable.Cells("BeginArrow")

objCell.Formula = "10"

objCell = objCable.Cells("EndArrow")

objCell.Formula = "10"

objCell = objCable.Cells("BeginArrowSize")

objCell.Formula = "0"

objCell = objCable.Cells("EndArrowSize")

objCell.Formula = "0"

System.Windows.Forms.Application.DoEvents()

Dim strTemp As String

strTemp = Left(strNodeAPort, 3)

If strTemp = "Fas" Then

' make it blue

objCell = objCable.Cells("LineColor")

objCell.Formula = "4"

End If

If strTemp = "Gig" Then

' make it Red

objCell = objCable.Cells("LineColor")

objCell.Formula = "2"

End If

Dim strNodeAConn As String

Dim strNodeBConn As String

strNodeAConn = "connections." & strNodeAPort

strNodeBConn = "connections." & strNodeBPort

Dim objBeginX As Visio.Cell

Dim objEndX As Visio.Cell

objBeginX = objCable.CellsSRC( _

visSectionObject, visRowXForm1D, vis1DBeginX)

If objNodeA.CellExists(strNodeAConn, False) Then

objBeginX.GlueTo(objNodeA.Cells(strNodeAConn))

Else

MsgBox("invalid start port nodea " & objNodeA.NameU & " " & strNodeAPort)

End If

objEndX = objCable.CellsSRC( _

visSectionObject, visRowXForm1D, vis1DEndX)

If objNodeB.CellExists(strNodeBConn, False) Then

objEndX.GlueTo(objNodeB.Cells(strNodeBConn))

Else

MsgBox("invalid end port nodeb " & objNodeB.NameU & " " & strNodeBPort)

End If

System.Windows.Forms.Application.DoEvents()

Catch err As Exception

subLogException(err)

subDisplayException(Nothing, err)

End Try

End Sub
 

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