Author Topic: Getting attributes by ID  (Read 4004 times)

ocroquette

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Getting attributes by ID
« on: July 20, 2007, 04:56:11 am »
Hi

With EA_OnPostNewAttribute, I get a "EA.EventProperties Info", from which I can get the new attribute's id (Info.Get(0).Value)

The problem is, I can't find any way to find this attribute from there.

There is no Repository.GetAttributesByID(), and I don't really understand that.
The same is true for the methods, ie. there is no GetMethodsByID(), while there are GetPackagebyID(), GetConnectorByID(), GetDiagramByID(),...

Any idea!?

Don't tell me I have to loop through all the attributes of all the elements to find my attribute! :P

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Getting attributes by ID
« Reply #1 on: July 20, 2007, 05:22:03 am »
This event is only triggered if you have successfully completed the process of adding an attribute. This event gives you the ID of the attribute, which is only assigned when creation is completed.

When you begin to add the attribute (i.e. have just opened the editor or something) the EA_OnPreNewAttribute event is triggered. The Info property for this event contains (among other things) a ParentID field that identifies the owning element.

You'll still have to blunder through the Attributes collection to find the one with the corrent ID. That's a pain, but no greater than what you'd have to handle in any case.

David
No, you can't have it!

thomaskilian

  • Guest
Re: Getting attributes by ID
« Reply #2 on: July 20, 2007, 05:53:25 am »
Does the attribute have a parent for which you can get ElementByID? (A shot in the dark from my Mac)

ocroquette

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: Getting attributes by ID
« Reply #3 on: July 20, 2007, 05:56:35 am »
Quote
This event is only triggered if you have successfully completed the process of adding an attribute. This event gives you the ID of the attribute, which is only assigned when creation is completed.

When you begin to add the attribute (i.e. have just opened the editor or something) the EA_OnPreNewAttribute event is triggered. The Info property for this event contains (among other things) a ParentID field that identifies the owning element.


That's clear to me.
However, EA could transmit the ParentID on EA_OnPostNewAttribute too. It would make life easier.


Quote
You'll still have to blunder through the Attributes collection to find the one with the corrent ID. That's a pain, but no greater than what you'd have to handle in any case.


It seems to me like an illogical limitation of the API. I will fill a feature request.

Thanks for your help!
« Last Edit: July 20, 2007, 05:58:33 am by ocroquette »

ocroquette

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: Getting attributes by ID
« Reply #4 on: July 20, 2007, 05:57:36 am »
Quote
Does the attribute have a parent for which you can get ElementByID? (A shot in the dark from my Mac)


Sure, but you still need to loop over all the attributes again to get the corresponding attribute as an object.

thomaskilian

  • Guest
Re: Getting attributes by ID
« Reply #5 on: July 20, 2007, 11:41:35 am »
That's usual behavior - category UI :(

I've definitely seen worse things. Even such where people do believe it's brilliant (Microsoft, to name one example). But what outstanding product could EA be without that Unique Interface?