Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: D. Schmid on July 21, 2015, 07:42:48 pm

Title: Adding Realization via script
Post by: D. Schmid on July 21, 2015, 07:42:48 pm
Hi @all,

I'm currently trying to add a realization from a class to an interface with a script.

Unfortunatelly this:

Code: [Select]
     
var eRealization;
eRealization = eClass.Realizes.AddNew (eInterface.ElementID, "Interface");
eRealization.Update ();
eClass.Realizes.Refresh();
eClass.Update();
eClass.Refresh ();
won't work

also this:

Code: [Select]
var eAssociation as EA.Connector;
eAssociation = eClass.Connectors.AddNew ("", "Realization");
eAssociation.SupplierID = eInterface.ElementID;
eAssociation.Direction = "Source -> Destination";
eAssociation.Update();
will throw an error at the update saying the Realization is not allowed "class --> interface"

How can I add a realization to a class using a script? In both cases the interface will also be created by the script.

Regards

Dominik
Title: Re: Adding Realization via script
Post by: qwerty on July 22, 2015, 07:23:53 am
I tried this with V9.3 and it worked. V12 failed. Looks like a bug. Will do a bit more testing.

q.
Title: Re: Adding Realization via script
Post by: qwerty on July 22, 2015, 07:31:31 am
I remember a recent similar thread. Turn off Tools/Options/Links(/Strict Connector Syntax and it works again. Still smells like a bug as the connector looks more than legal (it's even offered in the quick linker). Go ahead and send a bug report.

q.
Title: Re: Adding Realization via script
Post by: KP on July 22, 2015, 10:26:14 am
The second code snippet is the correct approach but it stopped working with EA 12, I think. It should have been fixed at 12.0.1213. From the readme:

Quote
Creation of new Realization connectors from automation restored

If it is still failing in a later edition, please send a bug report including the failing code snippet. And, as qwerty states, switching off Strict Connector Syntax is a work-around.
Title: Re: Adding Realization via script
Post by: qwerty on July 22, 2015, 07:16:37 pm
I don't have the very latest V12. I tested with 1208.

q.
Title: Re: Adding Realization via script
Post by: D. Schmid on July 23, 2015, 03:43:40 pm
Hi @all,

thank you for the quick Responses. The Workaround is working fine. I will test the script using 1215 today and will send a quick Feedback here and if necessary a little Bug Report. We currently use 1210 and there it didn't work.

Regards

Dominik
Title: Re: Adding Realization via script
Post by: D. Schmid on July 24, 2015, 03:43:42 pm
Hi again,

short Update. Just tested with 1215 and all works fine. Thank you all.

Regards

Dominik