Connecting 2 shape VB.net

Dec 20, 2013 at 6:44 AM
hello,

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.Create()

    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
        diagram.Shapes.Add(rectangle)
        s.Add(rectangle)
        If (x > 1200) Then
            x = 10
            y += 70
        End If
    Next
    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
        diagram.Shapes.Add(arrow)
        s.Add(arrow)
        'If (x > 1200) Then
        '    x = 10
        '    y += 70
        'End If
    Next



    '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)




    CachedRepository1.InsertAll(diagram)
    Display1.Diagram = diagram
    Display1.Invalidate()

Coordinator
Dec 20, 2013 at 11:45 AM
Hello,

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.