sys.exit( 1 )
else:
    meta_path = os.environ[ 'META_PATH' ]

destdir = meta_path + r"\src\Cyber2SFC_CodeGen\SF_CodeGen"
destfile = destdir + r"\Cyber2SFC_udm.mga"

if not os.path.exists( destdir ):
    os.makedirs( destdir )

gme.xme2mga( destdir + r"\Cyber2SFC_udm.xme", destfile )

mga = win32com.client.DispatchEx("Mga.MgaProject")
mga.Open( "MGA=" + destfile )

gme.mga2xme( meta_path + r"\generated\Cyber\models\CyberComposition_uml.mga" )
xme = win32com.client.DispatchEx("Mga.MgaParser")
xme.ParseProject(mga, meta_path + r"\generated\Cyber\models\CyberComposition_uml.xme")

mga.BeginTransactionInNewTerr()

SF_TypeBase = mga.RootFolder.ObjectByPath('/@CyberComposition|kind=Package/@Simulink|kind=Namespace/@Types|kind=ClassDiagram/@SF_TypeBase|kind=Class')
TypeBase = mga.RootFolder.ObjectByPath('/LINKS/NewClassDiagram/TypeBase')
TypeBase.Referred = SF_TypeBase

State = mga.RootFolder.ObjectByPath('/@CyberComposition|kind=Package/@Simulink|kind=Namespace/@Stateflow|kind=ClassDiagram/@State|kind=Class')
State_ref = mga.RootFolder.ObjectByPath('/LINKS/NewClassDiagram/State')
State_ref.Referred = State

Data = mga.RootFolder.ObjectByPath('/@CyberComposition|kind=Package/@Simulink|kind=Namespace/@Stateflow|kind=ClassDiagram/@Data|kind=Class')
Data_ref = mga.RootFolder.ObjectByPath('/LINKS/NewClassDiagram/Data')
if not os.path.exists( destdir ):
    os.makedirs( destdir )

# these output a file of the same name in the same directory
gme.xme2mga( vcp_path + r"\src\models\ESM2SLC\ESM2SLC.xme", destfile )

if paradigm != "CyPhyML":
    print "\"" + paradigm + "\" paradigm specified:  no transform will be executed"
    sys.exit( 0 )

print "Executing transform ...",
sys.stdout.flush()

# change the metaname of the UML diagram
gme.mga2xme( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.mga" )
with file( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme", "rb" ) as xme:
    lines = xme.readlines()
with file( meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme", "wb" ) as xme:
    for line in lines:
        xme.write(  line.replace( 'metaname="UML"', 'metaname="UMLModelTransformer"' )  )

mga = win32com.client.DispatchEx("Mga.MgaProject")
mga.Open( "MGA=" + destfile )

xme = win32com.client.DispatchEx("Mga.MgaParser")
xme.ParseProject(mga, meta_path + r"\generated\CyPhyML\models\CyPhyML_uml.xme")

mga.BeginTransactionInNewTerr()