Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: vignesh on September 25, 2017, 04:34:44 pm

Title: how to call an add-in when a element is added and any element values changed
Post by: vignesh on September 25, 2017, 04:34:44 pm
I have created an add-in and  added it to EA and its working fine and now i need to call the add-in when element is add or values of the element changed .If this is possible via trigger could you please give me a brief steps about how to do it.

Thanks in Advance.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: KP on September 25, 2017, 04:54:23 pm
EA will send out broadcasts when certain actions take place, so you need to create functions that respond to those broadcasts. For example, to respond to a new element being created, you will need to have a function called EA_OnPostNewElement. Search the help for "EA_OnPostNewElement" and it should point you in the right direction.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: vignesh on September 25, 2017, 06:43:01 pm
Thanks!!

Its really helpful..

I need to keep hold of the currently added element.Could you please help how to get it.


Thanks in Advance.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: qwerty on September 25, 2017, 08:13:34 pm
If you read the link for the operation KP mention you should know.

q.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: vignesh on September 26, 2017, 07:12:32 pm
I am getting index out of range error  when i use the broadcast function as mentioned above.Is there any work around or direct solution for it?

Thanks in advance.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: qwerty on September 26, 2017, 07:53:04 pm
Without knowing what you have done there I would need to look into my glass bowl. Unfortunately I had to send it in for maintenance yesterday.

q.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: Helmut Ortmann on September 26, 2017, 11:50:46 pm
Hi,

I would do:
- Check passed variables for 0/null
- Check variables for its values before using them
- Use a try {} catch {} block to handle exceptions
- Switch to DEBUG mode or use debug messages

Best regards,

Helmut
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: vignesh on September 27, 2017, 02:08:56 pm
I have written the below mentioned code in EA_OnPostNewElement function and the error index out of range is prompted.

 ElementID = int.Parse(info.Get("ID").Value);
 DiagramID = int.Parse(info.Get("DiagramID").Value);
 
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: KP on September 27, 2017, 03:07:45 pm
It's a long time since I wrote an add-in, but I don't think you're going to be passed a DiagramID in the EventProperties of EA_OnPostNewElement. Try getting the size of the EventProperties then loop through with Get(index) and see what's there - more reliable than guessing the property names.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: Geert Bellekens on September 27, 2017, 03:56:32 pm
There's no need to guess. The property names are all documented in the manual; you just have to read it.

Geert
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: KP on September 27, 2017, 04:04:20 pm
There's no need to guess. The property names are all documented in the manual; you just have to read it.

Geert

Correct. I've just checked it's neither "ID" nor "DiagramID".
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: vignesh on September 27, 2017, 06:37:49 pm
I need to get the name,type and etc from the newly created element in the EA_OnPostNewElement function is the possible??


Thanks in advance.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: Geert Bellekens on September 27, 2017, 06:46:40 pm
yes
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: vignesh on September 27, 2017, 08:26:28 pm
How to fetch it?

Thanks in advance.
Title: Re: how to call an add-in when a element is added and any element values changed
Post by: Geert Bellekens on September 27, 2017, 08:41:34 pm
How to fetch it?

Thanks in advance.
Sorry vignesh, you'll have to find another victim to send you teh codez.
I'm not playing.

Geert