Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Add a Connector

This is an example of code to add a connector and set its values.

Sub ConnectorTest

     Dim source as object

     Dim target as object

     Dim con as object

     Dim o as object

     Dim client as object

     Dim supplier as object

     ''Use ElementIDs to quickly load an element in this example

     ''... you must find suitable IDs in your model

     source = m_Repository.GetElementByID(129)

     target = m_Repository.GetElementByID(169)

     con = source.Connectors.AddNew ("test link 2", "Association")

     ''again, replace ID with a suitable one from your model

     con.SupplierID = 169

     If not con.Update Then

          Console.WriteLine(con.GetLastError)

     End If

     source.Connectors.Refresh

     Console.WriteLine("Connector Created")

     o = con.Constraints.AddNew ("constraint2","type")

     If not o.Update Then

          Console.WriteLine(o.GetLastError)

     End If

     o = con.TaggedValues.AddNew ("Tag","Value")

     If not o.Update Then

          Console.WriteLine(o.GetLastError)

     End If

     ''Use the client and supplier ends to set

     ''additional information

     client = con.ClientEnd

     client.Visibility = "Private"

     client.Role = "m_client"

     client.Update

     supplier = con.SupplierEnd

     supplier.Visibility = "Protected"

     supplier.Role = "m_supplier"

     supplier.Update

     Console.WriteLine("Client and Supplier set")

     Console.WriteLine(client.Role)

     Console.WriteLine(supplier.Role)

End Sub