[gme-users] FW: GME and python

Zoltan Molnar zolmol at isis.vanderbilt.edu
Thu Jun 16 10:34:53 CDT 2005


Hi,

Below is a sample script of using GME through Idispatch interface in
Python.
The other main creatable COM object is GME.Application. 
You can find the description of these interfaces in the GME/interfaces/
directory, especially in Mga.idl and Gme.idl.


import win32com.client
def createMyProject():
        """ Creates my SignalFlow project, with a Compound containing 5
Primitives"""
        project = win32com.client.Dispatch("Mga.MgaProject")
        mganame = "f:\\proj\\pdok\\pythonDemo\\gen1.mga"
        project.Create( "MGA=" + mganame, "SF")

        project.BeginTransaction( project.CreateTerritory( None, None,
None), 0)
        
        metaroot = project.RootMeta.RootFolder
        mfol = metaroot.LegalChildFolderByName( 'Folder')
        
        mkind = metaroot.DefinedFCOByName( 'Compound', 1)
        pkind = metaroot.DefinedFCOByName( 'Primitive', 1)
        metaroleOutSig = mkind.RoleByName( 'OutputSignals')
        metaroleInpSig = mkind.RoleByName( 'InputSignals')
        metaroleInpSig = pkind.RoleByName( 'InputSignals')
        metarolePrimit = mkind.RoleByName( 'PrimitiveParts')
        metaroleDFC    = mkind.RoleByName( 'DFC')
        
        # create a compound
        main = project.RootFolder.CreateRootObject( mkind)
        main.Name = 'Main'
        
        dst = main.CreateChildObject( metarolePrimit)
        dst.Name = 'DST'

        srcs = []
        for i in range(4):
                primit = main.CreateChildObject( metarolePrimit)
                primit.Name = 'SRC' + str(i)
                srcs.append( primit)
                
        insports = []
        for i in range(4):
                ins = dst.CreateChildObject( metaroleInpSig)
                ins.Name = 'InputSignal' + str(i)
                insports.append( ins)
        
        outsports = []
        for i in range(4):
                outs = srcs[i].CreateChildObject( metaroleInpSig)
                outs.Name = 'OutputSignal'
                outsports.append( outs)

        dummyColl = win32com.client.Dispatch("Mga.MgaFCOs")
        for i in range(4):
                main.CreateSimpleConn( metaroleDFC, outsports[i],
insports[i], dummyColl, dummyColl)

        
        project.CommitTransaction()

        project.Save()
        project.Close(0)

Br, Zoli

> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu 
> [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf 
> Of Matthew J. Emerson
> Sent: Thursday, June 16, 2005 9:25 AM
> To: gme-users; Thompson, Robert C
> Subject: [gme-users] FW: GME and python
> 
> 
> Hi Ace. This is a good question for the gme-users list, since 
> I don't have any personal experience with python model 
> interpreters. Does anyone have an example they could send?
> 
> --Matt
> 
> -----Original Message-----
> From: Thompson, Robert C [mailto:robert.c.thompson3 at boeing.com] 
> Sent: Wednesday, June 15, 2005 7:25 PM
> To: Thompson, Robert C; Akos Ledeczi; Matthew J. Emerson
> Subject: RE: GME and python
> 
> 
> I think a better way of saying that is:  do you know where I 
> can find more about using Python to interface to GME?  I'm 
> thinking it's through the Python COM module that is 
> available.... I guess I'm just looking for hints on how to 
> hook up to the GME app instance... from there I think
> (?) I can just use the COM interface to understand how to get 
> to the right objects, etc....
> 
> Thanks,
> -ace
> 
> > _____________________________________________ 
> > From: 	Thompson, Robert C  
> > Sent:	Wednesday, June 15, 2005 5:20 PM
> > To:	Akos Ledeczi; Matthew J. Emerson
> > Subject:	GME and python
> > 
> > Akos,
> > 
> > Do you know where I can find more about the Python interface to GME?
> > 
> > Thanks
> > -ace
> 
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> 


More information about the gme-users mailing list