Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: utilisateurEA on March 26, 2010, 02:05:39 am
-
Hello,
I would like to write a script in C# detecting every links (for example an association link) in my project, and their target.
I’ve found on the EA website an example describing how to find every tagged values and tried to adapt it for my case, but it doesn’t work.
I tried the following code :
String printedText="";
EA.Package aPackage;
aPackage = Repository.GetTreeSelectedPackage();
foreach (EA.Connector connect in aPackage.Connectors)
{
printedText = printedText + connect.ClientEnd.End + ",";
}
but nothing is printed when I display « printedText ».
I think I don’t even excecute the loop 1 time because if I write
foreach (EA.Connector connect in aPackage.Connectors)
{
printedText = “test”;
}
I have exactly the same result: nothing.
Do you have an idea to solve this problem ?
Thank you.
-
I've only ever used Element.Connectors, not Package.Connectors.
-
I've only ever used Element.Connectors, not Package.Connectors.
Has anybody ever used Package.Connectors?
Did it work?
Paolo
-
Indeed the result is better with Element.Connector.
Package.Connector didn't identify anything in my project (but maybe I have not the adapted objects)
Do you know how to hobtain the name of the target of the link ?
Because in Connector properties there are"ClientID" and "ClientEnd" but there is nothing in CleintEnd giving the name of the target.
(I have an idea using ClientID and then using it to find the name of the target, but there is surely a simpler method) ?
-
Use Repository.GetElementByID to get the element the connector is pointing to.
(not there is no simpler way)
Geert
-
OK thanks,
But what happen if the target is an operation or an attribute ? It will probably give the ID of the class containing the operation and not the ID of the operation ??
-
You can not have a connector to attributes or operations.
b.
-
In fact yes : it is possible to have a "generalize" link between a class and an operation, and even between 2 operations (you have to make a right click "link to element feature")
-
In fact yes : it is possible to have a "generalize" link between a class and an operation, and even between 2 operations (you have to make a right click "link to element feature")
You have to be careful... The linkage is (effectively) a rendering ONLY. The t_connector details - as beginner says - ONLY refer to the end Elements (not Features). It is NOT a simple matter to extract the rendering information and convert it to the (derived) Feature linkages.
HTH,
Paolo
-
In fact yes : it is possible to have a "generalize" link between a class and an operation, and even between 2 operations (you have to make a right click "link to element feature")
You're right, but that's still a link between elements. I do not know where they store the "Linked Element" information. Probably in the MiscData as this feature had been added in a later release of EA.
b.
P.S. Just checked in the database that at least half a dozen fields in the connector are changed with the Link Element and most of them are not available via the API.
-
P.S. Just checked in the database that at least half a dozen fields in the connector are changed with the Link Element and most of them are not available via the API.
how could you access to the MiscData informations of a connector ? I used get_MiscData but obtained nothing ?
-
There was a topic a few weeks ago about this "link to element" feature and how it is stored in the database.
Use the search button on the top left to try and find it.
Geert
-
P.S. Just checked in the database that at least half a dozen fields in the connector are changed with the Link Element and most of them are not available via the API.
how could you access to the MiscData informations of a connector ? I used get_MiscData but obtained nothing ?
I emphasized the relevant part.
b.
-
you can always use Repository.SQLQuery to get details from the database that are not exposed in the API.
Geert
-
How do you have details of what is contained in a connector for example ?
I don't really understand how a SQLQuery(string SQL) works :
do you have to write a SQL request in in the string or the name of the connector ?
(every time I try to use it I have "the SELECT statement includes a reserved word or an argument name is mispelled or missing")
Thank you !
-
try
Repository.SQLQuery("select * from t_connector")
to start with.
Geert
-
Thank you very much for your help !
-
Do you think that if I can't find a property with SQLQuery (I searched in many types like t_objects t-elements t-attributes) it means I can't obtain this property by script ?
-
EA has to store it somewhere, so you can definitely find it with an sql query.
I think the location of this "connect to element" feature in the database was discussed here a couple of weeks (months?) ago.
Use the top left "search" button to find it.
Geert