Here’s an interesting dilemma for you:

What if you start building your Enterprise Architecture model(s) in Archi and for various reasons, including scalability, you decide to migrate to another tool. But your existing model is based on ArchiMate 3.0 and your target environment only supports 2.1 for the time being.

This is what happened to me recently. At the time of writing Mavim (the target environment in question) only supports ArchiMate 2.1 but my models already used 3.0(.1) language features. Waiting for a 1.0 version of an import routine (with the expected undocumented features) wasn’t really an option. Additionally, the existing model could do with a bit of pruning. So it was decided to re-create the views in Mavim.

The only thing was that the model had some large views (450+ elements in a single view) and the elements all had documentation. So I really wanted a way to at least copy over the elements. Recreating the views / relations / etc. was an effort that I was willing to invest in a fresh, uncluttered EA model.

To facilitate this model migration I decided to use the Archi CSV export for models. This file was then transformed with a bit of python into an AMEFF (‘Open Group Exchange’) XML file. Finally the file would be imported in Mavim, and I would re-create the views.

There isn’t much information on such a scenario out there, so here’s a rough version of the python script to get people started. It’s pretty straight-forward. You probably need to tune valid_elements to your liking. The biggest quirk you’ll find is the empty view that is created near the end of the script. This is a necessary element for the Mavim import routine, where you have to select a view to import.


import csv

# Silly little script intended to take an Archi ( Archimate 3.0 model exported as .csv
# and export it to a Archimate 2.1 AMEFF file that can be read by Mavim. 
# This will only migrate the elements and you'll have to re-create the views / relationships / etc (!!!)
# -----=== Mavim Notes ===----- 
# To import the resulting XML file follow these steps:
# - Create a Topic for your EA model & select it;
# - Select "Modelling -> Overview -> Archimate" and wait for Visio to start;
# - In _Visio_, open the context menu on the drawing area "Import from Open Group Exchange file ..."
# - Select the file generated with this script ($> python3 > output.xml)
# - Ignore the validation warning and proceed without validation;
# - Select the "Migrated ArchiMate View" (which is an empty dummy view) and check "Import unused topics and relationships";
# - Import the file, and _save_ the Visio drawing to create the topics in your Mavim model.
# -----=== End Mavim Notes ===----- 
# CSV processing adapted from

# Which elements to transfer (Archimate 3 elements that are backwards compatible)
# Adjust to taste
valid_elements = {"BusinessActor", "BusinessFunction", "BusinessObject", "BusinessProcess", "BusinessRole", "ApplicationComponent", "ApplicationService", "DataObject", "TechnologyService"}

input_file_name = 'migration-elements.csv'

#-------------------------------------END CONFIG---------------------------------------

# Ah yes, XML. Didn't want to add another dependency...
def escape( str ):
    str = str.replace("&", "&")
    str = str.replace("<", "&lt;")
    str = str.replace(">", "&gt;")
    str = str.replace("'", "&apos;")
    str = str.replace("\"", "&quot;")
    return str

with open(input_file_name) as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    element_count = 0
    # Print XML HEADER
    print('<?xml version="1.0"?><model identifier="rxM006231C30000013E00000000S_model_MavimRules_v1" xmlns="" xmlns:xsi="" xsi:schemaLocation=""><name  xml:lang="en">Migrated elements</name><elements>')
    #Read each line and output an <element>    
    for row in csv_reader:
        if line_count == 0:
            #TODO header validation
            line_count += 1
            if row[1] in valid_elements:
                print(f'\t<element identifier="{row[0]}" xsi:type="{row[1]}"><label xml:lang="en">{escape(row[2])}</label><documentation>{escape(row[3])}</documentation></element>')
                element_count += 1
            line_count += 1
    #XML FOOTER -- Note: an empty view is added to facilitate the Mavim import routine...        
    print(f'<!--Processed {line_count} lines, with {element_count} valid elements.--></elements><views><view  identifier="rxMVNEWCHART00000000000000_view"><label xml:lang="en">Migrated ArchiMate View</label></view></views></model>')

More tk