This project has moved and is read-only. For the latest updates, please go here.

Connecting 2 shape

Dec 20, 2013 at 7:44 AM

I try to connect a set of shape using two databases.
1 base containing equipment, a second contains the links.

I got no problem to create the equipment, but the connection I do not see how.

Can you help me?

Enclosed is my code

    XmlStore1.DirectoryName = "C:\Documents and Settings\All Users\Common Files\NShape\Demo Projects"
    XmlStore1.FileExtension = "nspj"

    Project1.Name = "API DEMO"

    Project1.AddLibraryByName("Dataweb.NShape.electricalshapes", True)
    Project1.AddLibraryByName("Dataweb.NShape.ElectricalModelObjects", True)
    Dim diagram As New Diagram("Diagram")
    Dim rectangle As DisconnectorSymbol
    Dim shape As RoundedBox
    Dim shapeType As ShapeType = Project1.ShapeTypes("Disconnector")

    Dim x As Integer = 10
    Dim y As Integer = 10
    Dim s As ShapeCollection
    s = New ShapeCollection()
    Dim detail_equi As mydbDataSet.lst_equipementsRow
    For Each equi In Me.Lst_equipementsBindingSource
        detail_equi = CType(CType(equi, DataRowView).Row, mydbDataSet.lst_equipementsRow)
        rectangle = CType(shapeType.CreateInstance, DisconnectorSymbol)
        rectangle.Text = detail_equi.repere_equipement
        rectangle.Diameter = 100
        rectangle.X = x + 120

        rectangle.Y = y + 50
        x += 120
        If (x > 1200) Then
            x = 10
            y += 70
        End If
    Dim arrow As Polyline

    Dim link_equi As mydbDataSet.lst_dispo_tirageRow
    For Each row_equi In Me.Lst_dispo_tirageBindingSource
        link_equi = CType(CType(row_equi, DataRowView).Row, mydbDataSet.lst_dispo_tirageRow)
        arrow = CType(shapeType.CreateInstance, Polyline)

        arrow.X = x + 120

        arrow.Y = y + 50
        x += 120
        'If (x > 1200) Then
        '    x = 10
        '    y += 70
        'End If

    'For Each rectangle In diagram.Shapes
    '    for each xx In 

    '    Next
    '    arrow = CType(Project1.ShapeTypes("Polyline").CreateInstance(), Polyline)
    '    diagram.Shapes.Add(arrow)
    '    'arrow.Connect(ControlPointId.FirstVertex, , ControlPointId.Reference)

    Display1.Diagram = diagram

Dec 20, 2013 at 12:45 PM

please have a look at this thread.
You will find there a short summary about the concept of connection points and a sample on how to connect two shapes.

In the second loop of your sample, you need to get the two planar shapes that should be connected, first.
If you have these two shapes, you can create a line shape (arrow) and connect it with each planar shape.