Show Posts

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.


Messages - ScriptUser

Pages: [1]
1
Just as a final note on this one: Sparx support confirmed that there is indeed no possibility to do that by API.  :-[

2
So I tried with custom properties, but that does not seem to include the information of the info flow on the connector.
Basically I do not see any function or property in the API describtion that tells me anything about the t_xref information combination (what I am currently doing by writing intoSQL)

3
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
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+"%'";
You might be able to use the EA.Connector.CustomProperties to add this property to the association.

Geert

I know how to read out info of t_xref, but I am not able yet to write into it (add a new line) as I am missing a GUID. Also: I would rather prefer using the API instead of directly messing into the database.

For the CustomProperties Collection, according to the manual: "Notes: Read Only"

4
This code works

Code: [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

Ok, as you said, your code works for an informationFlow with an information Flow realized conveyed to it.

Just that "hidden" informationflow is something I have read already multiple times, but no one seems to neither get it to work or at least describe how he got it to work.
Really complicated implementation it seems...

Thanks already for your input!

5
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

I did not think about the newConnector.Update() BEFORE adding the conveyed item. However, that does not change anything.

For the:
Code: [Select]
dim conveyed
set conveyed = newConnector.ConveyedItems.AddNew("{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , "")
conveyed.Update

This throws an error on the last line (conveyed.Update) saying an object is missing. For me, it seems like it is not added and therefore there is no object. Completely lost on why to be honest.

To give you exact info:
The {16B42F4C-8038-495c-B5B4-73C8C76F1B43} is the GUID of an <<interfaceBlock>> that has on it a <<flowProperty>>

6
I thought that's what I tried by using
Code: [Select]
newConnector.ConveyedItems.AddNew InformationFlow , ""
I also tried
Code: [Select]
newConnector.ConveyedItems.AddNew "{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , NULLwhich shows a type conflict
or
Code: [Select]
newConnector.ConveyedItems.AddNew("{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , "")which shows not using () in case of sub routines
or
Code: [Select]
newConnector.ConveyedItems.AddNew "{16B42F4C-8038-495c-B5B4-73C8C76F1B43}" , ""which just does nothing
with {16B42F4C-8038-495c-B5B4-73C8C76F1B43} being the GUID of a block I want to use as the information flow.

7
I am using a VB script to create a connector by
Code: [Select]
Dim newConnector As EA.Connector
Set newConnector = ...Connectors.AddNew("", "Association")
newConnector.SupplierID = ...ElementID

I now want to add a conveyed item by
Code: [Select]
newConnector.ConveyedItems.AddNew InformationFlow , ""

The problem I have is: I do not see that in the diagram. And I also do not see the informationFlow being added in the t_xref database.

What I expected:
Manually, when I add a connector between two ports, then rightclick on it and use "Advanced" -> "Information Flows realized..." it will show the connector and the information flow that I put on it. It will in the database create a connector in the t_connector and a reference of the conveyed flow in the t_xref.
I want to mimic that behaviour by VB script and I am failing to find out, what to do to do the t_xref part.
Is the best option here an SQL insert query? (if yes, any idea how to create a GUID and check if it is not used already (I know probabilty is quite really low, but still).

Pages: [1]