Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: tonySparx on February 02, 2010, 01:44:40 am

Title: How to get the objectType from an ID
Post by: tonySparx on February 02, 2010, 01:44:40 am
Hi all,

I need to get objectType from an object ID, i.e. I have an object ID and I want to know what kind of object that is (otElement, otConnector and so on)?

I've already read the userGuide, but I suppose don't exists a method like " objectType getObjectByID(int ID)"...

Is there a way to implement my need in EA?

kind regards

Antonio

Title: Re: How to get the objectType from an ID
Post by: KP on February 02, 2010, 09:12:29 am
No, the ID isn't unique across all types.
Title: Re: How to get the objectType from an ID
Post by: Geert Bellekens on February 02, 2010, 06:14:21 pm
Antonio,

In that case you'll need to use the GUID property.
That would be (by its nature) unique amongst all objects.

Geert
Title: Re: How to get the objectType from an ID
Post by: mrf on February 03, 2010, 08:54:15 am
You do have two options in the following scenarios:

1. If it's the currently selected item you can call GetContextItemType()
2. If it's the currently selected item in the tree you can call GetTreeSelectedItemType()
Title: Re: How to get the objectType from an ID
Post by: tonySparx on February 06, 2010, 09:30:17 pm
Quote
Antonio,

In that case you'll need to use the GUID property.
That would be (by its nature) unique amongst all objects.

Geert

Thanks to all for help,

Geert, would be unique or IS unique? :D I've not found anything about this difference on the EA userguide...

Title: Re: How to get the objectType from an ID
Post by: Geert Bellekens on February 06, 2010, 10:53:18 pm
Tony,

"should", but with EA you never know ;)

Geert
Title: Re: How to get the objectType from an ID
Post by: Paolo F Cantoni on February 07, 2010, 12:37:58 pm
Quote
Quote
Antonio,

In that case you'll need to use the GUID property.
That would be (by its nature) unique amongst all objects.

Geert

Thanks to all for help,

Geert, would be unique or IS unique? :D I've not found anything about this difference on the EA userguide...

As a Data Architect, Tony, I learnt a LONG time ago that the term unique MUST always be accompanied by the context in which one is asserting uniquenesss...

For example, within a table such as t_object, the Object_ID is unique, but not across tables.  A GUID or UUID is notationally unique but only if you don't assign it to more than one entity.

Personally, I'd probably create a t_GUID table that had the GUID as the primary key, then the entity type (it was assigned to), and the entityID.  That way, I'd end up with a self-consistency mechanism that would assist in ensuring I didn't allocate the same GUID to more than one entity  (not that, so far, EA does).

HTH,
Paolo