[great-users] Externally Invoking the GreAT interpreters
Kevin Smyth
ksmyth at isis.vanderbilt.edu
Thu Feb 6 11:25:08 CST 2014
Hi Simon,
This code worked for me for the House2Order sample:
import win32com.client
import os.path
project = win32com.client.DispatchEx("Mga.MgaProject")
project.Open("MGA=" + os.path.abspath("House2Order.mga"))
launcher = win32com.client.DispatchEx("Mga.MgaLauncher")
selectobjs = win32com.client.DispatchEx("Mga.MgaFCOs")
currentobj = None
# If you have more than 1 config:
#project.BeginTransactionInNewTerr()
#currentobj = project.ObjectByPath("/@zz_Config/@Config")
#project.AbortTransaction()
launcher.RunComponent("MGA.Interpreter.GReAT Master Interpreter VC10",
project, currentobj, selectobjs, 128)
launcher.RunComponent("Mga.Interpreter.GreAT_CG_VC10", project, None,
selectobjs, 128)
project.Close(True)
A couple things to note:
GReAT requires you open the MgaProject with an absolute path
The interpreters require the "selectedobjs" parameter.
The 128 parameter in RunComponent is GME_SILENT_MODE from Mga.idl.
Kevin
On 2/6/2014 9:01 AM, Simon Görke wrote:
> Hi there,
>
> my intention is to (semi-)automate the re-interpretation, code generation
> and compilation required after updating the metamodels referred to within a
> GreAT rule.
> For this purpose, I am trying to invoke the GreAT interpreters from the
> command line using the following snippet of python code:
>
> -------
> from win32com.client import DispatchEx
>
> project = win32com.client.DispatchEx("Mga.MgaProject")
> project.Open("MGA=" + "rule.mga")
> launcher = win32com.client.DispatchEx("Mga.MgaLauncher")
> interpreter = "Mga.Interpreter.GreAT_CG_VC10"
> # or "Mga.Interpreter.GenerateConfig",
> "Mga.Interpreter.Generate GR", etc.
> launcher.RunComponent(interpreter, project, None, None, 0)
> -------
>
> This way, the interpreter is invoked, however it fails ('An error has
> occoured in component "Mga.Interpreter.GreAT_CG_VC10"').
> I am not sure how to go on now. Two things which come to mind are:
> 1. Are there any mandatory parameters I have to pass to the interpreters and
> if so, could you kindly point me to the definition in the GreAT sources (or
> documentation)?
> 2. Is it sufficient to simply invoke the "GreAT Master Interpreter" (which
> seems to call the other ones) or do I have to call
> Mga.Interpreter.GenerateConfig followed by Mga.Interpreter.Generate GR and
> so on?
> In the latter case: which interpreters are "hidden" behind the checkboxes of
> the master interpreter?
>
> Thanks in advance,
> Simon
>
> _______________________________________________
> great-users mailing list
> great-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users
More information about the great-users
mailing list