Author Topic: how to call an add-in when a element is added and any element values changed  (Read 6502 times)

vignesh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-1
    • View Profile
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.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
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.
The Sparx Team
[email protected]

vignesh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-1
    • View Profile
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.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
If you read the link for the operation KP mention you should know.

q.

vignesh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-1
    • View Profile
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.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
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.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
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
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

vignesh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-1
    • View Profile
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);
 

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
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.
« Last Edit: September 27, 2017, 03:09:30 pm by KP »
The Sparx Team
[email protected]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
There's no need to guess. The property names are all documented in the manual; you just have to read it.

Geert

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: how to call an add-in when a element is added and any element values changed
« Reply #10 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".
The Sparx Team
[email protected]

vignesh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-1
    • View Profile
Re: how to call an add-in when a element is added and any element values changed
« Reply #11 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: how to call an add-in when a element is added and any element values changed
« Reply #12 on: September 27, 2017, 06:46:40 pm »
yes

vignesh

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-1
    • View Profile
Re: how to call an add-in when a element is added and any element values changed
« Reply #13 on: September 27, 2017, 08:26:28 pm »
How to fetch it?

Thanks in advance.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: how to call an add-in when a element is added and any element values changed
« Reply #14 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