Book a Demo

Author Topic: Get Relation between Components  (Read 6043 times)

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Get Relation between Components
« on: March 19, 2013, 02:26:05 am »
How can I grammatically get the relationship between a component and another component if they are connected together

Patrick Julian

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #1 on: March 19, 2013, 03:16:28 am »
What do you mean by "gramatically get"?

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #2 on: March 19, 2013, 03:20:18 am »
sorry
I mean Programmatic ,using C#
to iterate  the connections between the components

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Get Relation between Components
« Reply #3 on: March 19, 2013, 07:16:39 am »
You need to iterate the connectors and get the elements for the objectId from source/target.

q.

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #4 on: March 19, 2013, 10:14:44 am »
can u plz give me more details !!
thanx

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Get Relation between Components
« Reply #5 on: March 19, 2013, 10:55:21 am »
Code: [Select]
con = element.Connectors.GetAt (0);
print con.Type;
print con.Direction;
target = repository.GetElementByID (con.ClientID);
print target.Name;

q.

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #6 on: March 19, 2013, 11:28:34 am »
con = element.Connectors.GetAt (0);  ## it is not correct

because element.Connectors.GetAt (0) retruns object not Connector.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Get Relation between Components
« Reply #7 on: March 19, 2013, 11:57:10 am »
You may need to typecast it:

Code: [Select]
con = (EA.Connector)element.Connectors.GetAt(0);
The Sparx Team
[email protected]

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #8 on: March 19, 2013, 12:00:52 pm »
Tx
I did something like

 Connector C=(Connector )(ie.Current );
but how can I find the source type and the target type  at the connector object ?
« Last Edit: March 19, 2013, 12:01:40 pm by itman »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Get Relation between Components
« Reply #9 on: March 19, 2013, 12:15:20 pm »
Quote
but how can I find the source type and the target type  at the connector object ?
Open the help file and go to "Automation and Scripting > Enterprise Architect Object Model > Reference > Connector Package > Connector" and in the table there find the attributes that represent "The ElementID of the element at the source end of this connector" and "The ElementID of the element at the target end of this connector". Qwerty has already suggested what to do with these IDs.

HTH :)
The Sparx Team
[email protected]

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #10 on: March 19, 2013, 12:37:53 pm »
I have already red the file >> References ,
but , I cann't find the solution ..
so please help me..
tx :(

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Get Relation between Components
« Reply #11 on: March 19, 2013, 01:51:21 pm »
Open the help file and go to "Automation and Scripting > Enterprise Architect Object Model > Reference > Connector Package > Connector Class" and then in the Connector Attributes table look for ClientID and SupplierID.

If this does not help you, along with Qwerty's valuable advice, you might need to rethink the task you have set yourself and do some more-basic research on using the API.
Best Regards, Roy

mohammed

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Get Relation between Components
« Reply #12 on: March 19, 2013, 03:09:11 pm »
tx,
I did all

but I think the help need to be more easy by adding examples.
 ;)