Author Topic: cast an EA.Element to an Object  (Read 3681 times)

defi

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
cast an EA.Element to an Object
« on: July 24, 2012, 02:26:27 am »
Hi!
I created an object Client with all the properties I want this Object to have. Now i want and object of type EA.Element of a Diagram to cast in an object Client. How can i do that?

I tried with
Code: [Select]
EA.Element node;
Client thisNode = (Client)node;

but it doesn't work, it gives me an exception.

Can please someone help me.
Thank you a lot. And please don't tell me that I'm a noob and that I have to start over to study programming. I want some help to solve this easy (for an expert) problem. Thank you  :)

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: cast an EA.Element to an Object
« Reply #1 on: July 24, 2012, 03:29:44 am »
You can't cast an EA.Element to a Client or any other type since you have no control over the creation of instances of EA.Element. You can only obtain references to EA.Element's already created for you by EA.

So, what exactly are you trying to achieve?
« Last Edit: July 24, 2012, 03:30:28 am by pmaessen »

defi

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: cast an EA.Element to an Object
« Reply #2 on: July 24, 2012, 03:31:55 am »
i resolved the thing, with the following code:

Code: [Select]
EA.Element node;
Client thisNode = new Client(node.ElementID);


Thank you for your help.

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: cast an EA.Element to an Object
« Reply #3 on: July 24, 2012, 07:40:19 am »
Quote
And please don't tell me that I'm a noob and that I have to start over to study programming. I want some help to solve this easy (for an expert) problem

This quote + this solution?

Code: [Select]
EA.Element node;
Client thisNode = new Client(node.ElementID);

i lol'd...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: cast an EA.Element to an Object
« Reply #4 on: July 24, 2012, 03:17:18 pm »
I think he should have use something like
Code: [Select]
Client thisNode = ***(Client)node***; The *** indicate the fairy dust, which activates the code magic ;D

Geert