1
Automation Interface, Add-Ins and Tools / Re: Adding Conveyed Items to a connector
« on: August 07, 2024, 04:28:29 pm »
Just as a final note on this one: Sparx support confirmed that there is indeed no possibility to do that by API.

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
It's not really that complicated.
You need to make an informationflow (like in the code I shared) and then link it to the association.
The link between the association and the informationflow is made in the t_xref of the association.
This is the code that gets the id's of the other connectors when starting from the information flow.Code: [Select]// because access doesn't want to join on the description field (memo) we cannot use proper SQL join syntax
You might be able to use the EA.Connector.CustomProperties to add this property to the association.
string sqlGetRealization = @"select crel.Connector_ID from t_connector c, t_xref x, t_connector crel
where x.Name = 'MOFProps'
and crel.ea_guid = x.Client
and c.ea_guid = '" + this.guid + "'"
+" and x.Description like '%"+this.guid+"%'";
Geert
This code worksCode: [Select]dim sourceClass as EA.Element
set sourceClass = Repository.GetElementByGuid("{EDFA7390-50D6-4987-9905-DB1122341F6C}")
dim targetClass as EA.Element
set targetClass = Repository.GetElementByGuid("{3ABFB810-1613-4f82-B74A-CCF3F8526B01}")
dim conveyedClass as EA.Element
set conveyedClass = Repository.GetElementByGuid("{579CBCCE-354E-482e-B23A-1B9EF0EB5876}")
dim connector as EA.Connector
set connector = sourceClass.Connectors.AddNew("new flow", "InformationFlow")
connector.SupplierID = targetClass.ElementID
connector.Update
'add conveyed item
connector.ConveyedItems.AddNew conveyedClass.ElementGUID, ""
'reload
Repository.ReloadPackage sourceClass.PackageID
There is something special if you want to add conveyed items to something different then an informationflow (like an association in your case). In that case EA generates an "hidden" informationflow that is then linked to your association.
I think you'll need to replicate that if you really need the connector to be an association.
Geert
Did you Update() the connector before trying to add a conveyed item?
If it then still doesn't work you could try:Code: [Select]dim conveyed
set conveyed = newConnector.ConveyedItems.AddNew("{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , "")
conveyed.Update
But I think it's more likely to be the lack newConnector.Update()
Geert
dim conveyed
set conveyed = newConnector.ConveyedItems.AddNew("{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , "")
conveyed.Update
newConnector.ConveyedItems.AddNew InformationFlow , ""
newConnector.ConveyedItems.AddNew "{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , NULL
which shows a type conflictnewConnector.ConveyedItems.AddNew("{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , "")
which shows not using () in case of sub routines newConnector.ConveyedItems.AddNew "{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , ""
which just does nothingDim newConnector As EA.Connector
Set newConnector = ...Connectors.AddNew("", "Association")
newConnector.SupplierID = ...ElementID
newConnector.ConveyedItems.AddNew InformationFlow , ""