Blog Post

Import Model Patterns through Add-in

In this article we will brief how to share a model pattern to a large group. In general model pattern can be included along with MDG definition file and can be used. There are certain limitations in this approach while importing MDG to a shared model and many people use it. To overcome we decided to create an external program and to refer Pattern and share the installer to users.


The reader has a fairly good understanding of creating an Enterprise Architect Addin or writing an application that can use Enterprise Architect. Refer to below references if you need more information on these

  • To create an Addin from scratch refer this link 
  • Download Skeleton for creating an Add-In using the C# Language from this link

Steps to follow:

  • Create & Save custom pattern as XML (Export as XMI)
  • Create MDG file
  • Create an external project
  • Reuse Patterns from Model Wizard Window

Create MDG File:

Create MDG file for patterns by copying the below syntax

<?xml version=”1.0″ encoding=”windows-1252″?>

<MDG.Technology version=”1.0″><Documentation id=”SSIN” name=”Sparx Technology” version=”1.0.0″ notes=”Sparx Systems India Patterns Sample”/><Logo><Image type=”bitmap” xmlns:dt=”urn:schemas-microsoft-com:datatypes” dt:dt=”bin.base64″>



<Model name=”Motivation Layer” description=”Create Motivation Layer.” location=”Motivation Layer.xml” default=”” icon=”34″ filter=””/>

<Model name=”Business Layer” description=”Create Business Layer.” location=”Business Layer.xml” default=”” icon=”34″ filter=””/>



Create an external project

Create an external program. Add the XMI and MDG Definition as resources. Use EA_OnInitializeTechnologies to pass an MDG Technology to Enterprise Architect for loading. This event occurs on Enterprise Architect startup. Return your technology XML to this function and Enterprise Architect loads and enables it. Refer the below code

#region MDG Load

//Load MDG Files
public object EA_OnInitializeTechnologies(EA.Repository Repository)

string sTechnologyXML = Properties.Resources.Sparx_Technology;
return sTechnologyXML;



Use EA_OnRetrieveModelTemplate event occurs when a user executes the Add a New Model Using Wizard command. Below code refers to Motivation Layer & Business Layer XMl referred in resources of the external project.

public virtual string EA_OnRetrieveModelTemplate(EA.Repository Repository,string sLocation)

string sTemplate = “”;

switch (sLocation)

case “Motivation Layer.xml”:
sTemplate = global::SparxAddin.Properties.Resources.Motivation_Layer;
case “Business Layer.xml”:
sTemplate = global::SparxAddin.Properties.Resources.Business_Layer;


catch (Exception ex)
return sTemplate;


Reuse Patterns from Model Wizard Window

Install the Add-In. After installation, Click the Specialize (Extend in Enterprise Architect 13.5) | Add-In | Manage to verify whether the Add-In installed properly. Create a model try to add the Model Wizard.

Note: To display custom patterns add technology to custom perspective or click show all perspectives

Leave a Comment