Book a Demo

Author Topic: Create Sequence Connector Programmatically  (Read 5621 times)

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Create Sequence Connector Programmatically
« on: February 22, 2015, 08:51:24 pm »
I would like to create programmatically a self-connector, using C#.

This is how I do it in case of an Association connector:
Code: [Select]
//Create new Association connector
object connectorObject = selElement.Connectors.AddNew("NewConnector", "Association");
EA.Connector connector = connectorObject as EA.Connector;
if (connector != null)
  {
    //self-connector
    connector.SupplierID = selElement.ElementID;
    connector.ClientID = selElement.ElementID;

    connector.Update();
    selElement.Update();
    selDiagram.Update();
  }


But when I try to create a sequence connector I get the following error:
Code: [Select]
object connectorObject = selElement.Connectors.AddNew("NewConnector", "Sequence");
Error: Sequence is not legal for Class -> Class.


Any ideas?
« Last Edit: February 22, 2015, 08:52:09 pm by avoda234 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #1 on: February 22, 2015, 09:21:03 pm »
The message is correct. In a sequence diagram you need to have instances, not classes.

q.

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #2 on: February 22, 2015, 10:42:41 pm »
Quote
The message is correct. In a sequence diagram you need to have instances, not classes.

q.

You're right.

I dragged the classes as lifelines to the sequence diagram.
Now I get the following error: "Sequence is not legal for Object to Object".

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #3 on: February 22, 2015, 11:57:46 pm »
lol - I had no issue creating a sequence with this Perl snippet:

Code: [Select]
my $e = $rep->GetTreeSelectedObject();
my $con = $e->Connectors->AddNew("test", "Sequence");
$con->{SupplierID} = $e->ElementID;
$con->Update();

The selected element was a simple lifeline. Sequence connectors are meant to work with lifelines in SDs. I was able to create a sequence connector for an object but it will not show in the class diagram.

q.
« Last Edit: February 23, 2015, 01:04:36 am by qwerty »

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #4 on: February 23, 2015, 01:22:45 am »
Thanks for the test.

What version of EA do you use? I have the full 12. May this is the reason?
And a rude question: Why didn't you try the C# code? :)


KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #5 on: February 23, 2015, 08:58:37 am »
There is an issue with creating sequence messages in automation. I believe a fix will be in the next release. Until then, try turning off syntax checking: Tools > Options > Links > Strict Connector Syntax.

[edit]12.0.1208 has been released. http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1424649387: "Sequence messages can now be created from automation with strict connector syntax enabled"[/edit]
« Last Edit: February 23, 2015, 11:00:21 am by KP »
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #6 on: February 23, 2015, 10:30:03 am »
I also tested with V12.

I simply don't use Cxx because Perl is by far more easy to create such simple code snippets. I only installed a Cpp compiler (for the first time on a Windoze machine) for a test where Perl could not work (something with add-ins). I'd rather use Ruby but that did not really make it except for Rails. And Perl is one of the few languages which run the same on Mac, Linux and Windoze. (Yes, Cpp too, but I regularly have to vomit over my keyboard when I have to deal with DLLs and all that windoze stuff).

q.

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #7 on: February 23, 2015, 06:28:57 pm »
Quote
There is an issue with creating sequence messages in automation. I believe a fix will be in the next release. Until then, try turning off syntax checking: Tools > Options > Links > Strict Connector Syntax.

[edit]12.0.1208 has been released. http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1424649387: "Sequence messages can now be created from automation with strict connector syntax enabled"[/edit]

Thank you all!
Deselecting the checkbox, make it work, indeed.
What are the consequences of deselecting it?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create Sequence Connector Programmatically
« Reply #8 on: February 23, 2015, 09:45:32 pm »
It will not complain :-)

In other words: you can create non-comformant UML. So Yoda speak you can, UML you use.

q.
« Last Edit: February 23, 2015, 09:47:59 pm by qwerty »