Book a Demo

Author Topic: C# Add-In-TransformPackage, Import of Transform Templates and Code Templates  (Read 4734 times)

Tschana

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Hello all,
First of all I want to mention that I'm totally new to EA.

I managed to program some basic tasks like adding some packages, create diagrams or to start the model transformation from a specific package using the TransformPackage function:
Code: [Select]
EA.Repository.GetProjectInterface().TransformPackage(string TransformName, string SourcePackage, string TargetPackage, string ExtraOptions);
My first question: can someone explain me what strings can be used for the "ExtraOptions"?

Secondly I didn't find a way to import a transformation template (which I exported through the "Export Reference Data"-Tool from EA). I searched for a method but didn't find one. Can you please give me a short example of how to import a transform template with C#. If it's possible to import a transformation template, are the modified templates like e.g. "File" or "Class" also updated?

And another question: Is the process for importing code templates (for generating source code) the same as for transformation templates?

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
The API is documented in the help : http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/automation/project_2.html
In this case:
Quote
TransformPackage (string TransformName,
string SourcePackage,
string TargetPackage,
string ExtraOptions)

Boolean

Notes: Runs a transformation on the contents of a Package.

Parameters:

TransformName: String - specifies the transformation that should be executed
SourcePackageGUID: String - the GUID (in XML format) of the Package to transform
TargetPackageGUID: String - the GUID (in XML format) of the Package to transform into
ExtraOptions: String - enables extra options to be given to the command:
     -  GenCode=True/False - articulate code generation from the transformed elements;
        this option supercedes the current model setting
     -  SubPackages=True/False - specify if the child Packages are to be included whilst
        transforming a Package

Geert

Tschana

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Thanks Geert for answering to my first question.

Do you have any suggestions for my other questions (import model and code transformation templates to EA through an ADD-In)?

Tschana

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
I just found a solution with the undocumented command CustomCommand:
Code: [Select]
Repository.CustomCommand("Repository", "ImportRefData", ExampleModelTransformation.xml);
Is it advisable to use the CustomCommand or is there any other way for importing special transformations via c#?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
If there is a CustomCommand, that usually means there's no other way of doing it.
If there would be another way it woud probably be found on EA.Repository or EA.Project

Geert