Book a Demo

Author Topic: How to create a reference of a port element  (Read 4043 times)

patson

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
How to create a reference of a port element
« on: July 08, 2010, 05:59:58 am »
Hallo,

I have the following problem and hope somebody could help me.
using AI I have create a class element "element1" that containt an embedded element "port1".
I have create a instance of element1 (element1Instance) and I want to add reference of port1(port1Ref) into element1Instance.
I want to create a new port and set it as reference to port1
I know that port1Ref.MiscData[2] = port1.elementGUID, but the problem is that I cannot set the MiscData[2] of an element.

I will very thankful when somebody can help me

Patjoe

beginner

  • Guest
Re: How to create a reference of a port element
« Reply #1 on: July 08, 2010, 05:13:39 pm »
MiscData is read only (see docu). You have to either tweak the database directly or request a new feature.

b.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to create a reference of a port element
« Reply #2 on: July 08, 2010, 05:28:56 pm »
Shouldn't you work with the embeddedElements collection somehow?
In other words, add an embedded element to the instance of type Class.port1?

If this won't work you can use Repository.Execute(SQLstring) to execute update statements on the database directly.

Geert

patson

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: How to create a reference of a port element
« Reply #3 on: July 08, 2010, 06:27:03 pm »
Hi Geert,
Of course I use the embeddedElements collection. But I need the port reference to add them to the embeddedElements collection and I don´t know how to have this port reference. I write the AddIn in C# and I don´t know the fonction Repository.Execute(SQLstring).
Manually I use "Add EmbeddedElements" to add port reference to an instance, but in C# I don´t how do to that.

Regards

Patjoe

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to create a reference of a port element
« Reply #4 on: July 08, 2010, 06:32:15 pm »
Patjoe,

I'm not sure, but I guess you'll need to add an embedded element of type port to the instance, and then somehow set the reference to the classifiers port.
It might be that you need to set the classifier ID of the (instance)port, or something else...

The Repository.Execute is an undocumented operation that will execute a random sql string. So you can use that to make updates to the database directly.

Geert