Book a Demo

Author Topic: Add-in export to xml  (Read 6328 times)

Radiogamer

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Add-in export to xml
« on: September 14, 2016, 05:07:40 pm »
Hello all,

I'm fairly new with the use of Enterprise Architect and things are going good. I'm currently checking out add-ins and am trying to build one myself. Right now I got a simple add-in working that opens a message saying "Hello World".

What I'm wondering is if it's possible to call functionalities of EA from the add-in. I'd like to be able run my add-in on a model to have it converted to xml and stored in the same directory as the model. Hence is it possible to perform this in an add-in, and if so what kind of methods should I use?

Thanks in advance.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Add-in export to xml
« Reply #1 on: September 14, 2016, 06:18:41 pm »
What do you mean by "converted to xml"?
Do you mean export to XMI?
In that case you can use EA.Project.ExportPackageXMI

I have an example on my Package wrapper class that uses that function

Code: [Select]
/// <summary>
/// export this package to xmi in the default format
/// </summary>
/// <param name="filePath">the filepath to save the xmi file to</param>
public void exportToXMI(string filePath)
{
this.model.getWrappedModel().SuppressEADialogs = true;
var projectInterface = this.model.getWrappedModel().GetProjectInterface();
string xmlGUID = projectInterface.GUIDtoXML(this.guid);
projectInterface.ExportPackageXMI(xmlGUID,global::EA.EnumXMIType.xmiEADefault,2,3,1,0,filePath);
this.model.getWrappedModel().SuppressEADialogs = false;
}

Geert

Radiogamer

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Add-in export to xml
« Reply #2 on: September 14, 2016, 06:53:42 pm »
Ah yes, I indeed meant "Export to XMI". As I said I'm a bit new, so I still need to get used to this.

Thanks for an example. I will take a look into it and see if I can get my add-in working.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Add-in export to xml
« Reply #3 on: September 14, 2016, 08:50:37 pm »
If you look in the manual, you'll see that the API is split into one Object Model and one Add-In Model.

The Add-In Model is actually a superset of the Object Model. In other words, an Add-In can do everything a script or a stand-alone C# application (which use the Object Model) can do, but not the other way around.

What makes an Add-In special is that it can respond to events fired by EA, which in the source code means that it implements a number of callbacks (as listed in the Add-In Model), and in runtime that it executes within the context of an EA process.

/Uffe
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Add-in export to xml
« Reply #4 on: September 19, 2016, 01:52:25 pm »
My pocket summary of the two parts of the API documentation...

The add-in model defines how/when EA can call your code.

The object model defines how you can call EA code (including when EA calls yours.)