Author Topic: EA_OnPostNewElement / GUID in EA.EventProperties?  (Read 3515 times)

mlk

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
EA_OnPostNewElement / GUID in EA.EventProperties?
« on: February 04, 2013, 02:36:40 am »
Is there a possibility to get object GUID directly from
EA.EventProperties info (i.e. "string str = info.Get("GUID").Value;")?


The Get works only for "string str = info.Get("ElementID").Value; ". I've tried with "GUID", "Guid", "ea_guid". Only exception message is "stable" and easy to predict ;)

Rgds,
Maciek

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: EA_OnPostNewElement / GUID in EA.EventProperti
« Reply #1 on: February 04, 2013, 03:03:15 am »
AFAIK it's only possible to get the EA object related to the event by ID (named 'PackageID', 'ElementID', 'AttributeID', etc.). You can get the GUID using the object instance after a call to Repository.GetPackageByID(), Repository.GetElementByID(), Repository.GetAttributeByID(), etc. accordingly.
You might find this class from Geert Bellekens EA Addin Framework helpful for dealing with event properties: EventPropertiesHelper

HTH
Günther
« Last Edit: February 04, 2013, 07:41:19 am by g.makulik »
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: EA_OnPostNewElement / GUID in EA.EventProperti
« Reply #2 on: February 04, 2013, 06:29:21 am »
Hi,

you can get it with

        public System.Object EA_OnPostNewElement(EA.Repository repository, EA.EventProperties info)
        {
            EA.EventProperty prop = (EA.EventProperty)info.Get(0);
            EA.Element newElement = repository.GetElementByID(int.Parse(prop.Value.ToString()));

Than you have the element defines as EA.Element an can get it's guid with element.elementguid

Regards

Stefan

Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

mlk

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: EA_OnPostNewElement / GUID in EA.EventProperti
« Reply #3 on: February 05, 2013, 01:28:54 am »
Thanks for your replies. I forgot to mention I want to avoid too many interactions with EA.Interop methods, just for performance reason. Thanks.

Now I know that it’s impossible in COM model to get the GUID directly from within EA.EventProperties.
The only way IMHO is to use  EA_OnNotifyContextItemModified(EA.Repository repo, String GUID, EA.ObjectType ot) instead of EA_OnPostNewElement(EA.Repository repo, EA.EventProperties info).


Maciek