Book a Demo

Author Topic: Starting to develop add ins  (Read 5036 times)

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Starting to develop add ins
« on: March 10, 2010, 01:26:28 am »
Hello everyone
I am just starting to look at developing some EA Addins.
THought I might start by creating a diagram when the user has a UseCase selected.
I looked at the c# samples and see how to get menus operating, however, these samples dont show what can be done after.
For example how do I know what type of element is selected when the menu is in operation. What are the commands to add a diagram etc
Any help is appreciated

Graham
Using V12

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Starting to develop add ins
« Reply #1 on: March 10, 2010, 01:53:49 am »
Graham,

To find out which type of object is select you can use following:

Code: [Select]
Object selectedItem;
EA.ObjectType selectedType = Repository.GetContextItem(out selectedItem);

To add a diagram to an element or a package you have to use the Element.Diagrams.AddNew(name,type) or Package.Diagrams.AddNew(name,Type).

Furthermore there are two very important functions to remember:
Update() (exists on almost any object): saves the object to the database
Collection.Refresh(): refreshes the collection (in memory). If you don't call this operation then you won't find the new element in the collection unless you reload it from the database.

As a last note I would strongly suggest to wrap all EA classes into your own classes so you can reuse all the convenience methods you are bound to make. I've written down the way I structure my tools on EA in this pattern article: http://themodelfactory.org/Pattern:Modelling_Tooling_Framework

Geert
« Last Edit: March 10, 2010, 01:54:17 am by Geert.Bellekens »

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: Starting to develop add ins
« Reply #2 on: March 10, 2010, 01:57:27 am »
Thanks Geert - I'm on my way now!!
Using V12

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: Starting to develop add ins
« Reply #3 on: March 10, 2010, 03:50:29 am »
Hi Geert
So I can now create a diagram under the element that I want.
 
Now, how do I gett he diagram displayed once it has been created?

Graham
Using V12

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Starting to develop add ins
« Reply #4 on: March 10, 2010, 04:01:12 am »

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: Starting to develop add ins
« Reply #5 on: March 10, 2010, 04:01:59 am »
Thanks
I'm having trouble finding the information I want in the help!

Graham
Using V12

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Starting to develop add ins
« Reply #6 on: March 10, 2010, 04:42:59 am »
Yes, it's not always straightforward. One might expect to find this functionality bound to the Diagram object itself instead. As a rule of thumb: If you don't find it bound with the EA Automation-Interface class you're working with, look in the Repostory classes methods to find s.th. appropriate  ;).

WBR
g.