Book a Demo

Author Topic: Creating a connector between element and connector in C#  (Read 4417 times)

fico_addins

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Creating a connector between element and connector in C#
« on: March 01, 2019, 06:34:18 pm »
Hi,

I'm trying to create a connector between a dynamically created element (requirements) and a connector.

In concrete, what i'm trying to do is shown in the image below:


I create the requirements in a C# add-in for the elements (states) and connectors (state flows).

Using the API to link these requirements works good for the states (using connector SupplierID) but for connectors it isn't working, as SupplierID receives an ElementID and does not accept connector ID's.

I tried updating the tables
Code: [Select]
Repository.Execute("UPDATE t_connector SET Start_Object_ID = " + connector.ConnectorID + "AND End_Object_ID = " + newReq.ElementID + " WHERE Connector_ID = " + connector.ConnectorID);
and creating conveyed items:
Code: [Select]
connector.ConveyedItems.AddNew(newReq.ElementGUID, null);
but nothing seems to work.
How can I link these requirements to the connector to show up in the model?

Thank you!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creating a connector between element and connector in C#
« Reply #1 on: March 01, 2019, 07:39:52 pm »
I never touched this construct. IIRC EA creates an internal object for the connector as a doppelgänger. (Just a memo to add this to my Inside book.)

q.

P.S. Yes. It's a ProxyConnector element which is created.
« Last Edit: March 01, 2019, 07:42:58 pm by qwerty »

fico_addins

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Creating a connector between element and connector in C#
« Reply #2 on: March 01, 2019, 08:50:59 pm »
I never touched this construct. IIRC EA creates an internal object for the connector as a doppelgänger. (Just a memo to add this to my Inside book.)

q.

P.S. Yes. It's a ProxyConnector element which is created.

Thank you so much for your answer. Indeed, I needed to create a ProxyConnector element. Now everything is correctly linked.

For people who may have this problem in the future, this question gave me the solution:
https://www.sparxsystems.com/forums/smf/index.php?topic=41346.0

The code goes like this:
Code: [Select]
EA.Connector connector = (EA.Connector)requirement.Connectors.AddNew("", "");
EA.Element connectorProxy = (EA.Element)this.package.Elements.AddNew("", "ProxyConnector");
connectorProxy.ClassifierID = target; //The stateflow connector ID where I want to point to.
connectorProxy.Update();

this.Repository.Execute("UPDATE t_object SET Classifier_guid='" + this.Repository.GetConnectorByID(target).ConnectorGUID + "' WHERE Object_ID=" + connectorProxy.ElementID + ";");
connector.SupplierID = connectorProxy.ElementID;