Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: mlk on February 04, 2013, 02:36:40 am

Title: EA_OnPostNewElement / GUID in EA.EventProperties?
Post by: mlk 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
Title: Re: EA_OnPostNewElement / GUID in EA.EventProperti
Post by: g.makulik 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 (https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/Utilities/EventPropertiesHelper.cs)

HTH
Günther
Title: Re: EA_OnPostNewElement / GUID in EA.EventProperti
Post by: Stefan Bolleininger 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

Title: Re: EA_OnPostNewElement / GUID in EA.EventProperti
Post by: mlk 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