[gme-users] JScript Resources

Zoltan Molnar zolmol at isis.vanderbilt.edu
Thu Dec 14 15:59:34 CST 2006


Hi,

I have no such working example in Jscript. I have used Python code till
now, and I have created this VBScript code right now for the example's
sake. I could not figure out the Jscript counterpart of 'Nothing' or
'None' (VBScript/Python) that is required in the CreateTerritory call.
In JavaScript the 'undefined' keyword can be used there, but Jscript
complains about that.
The interesting thing is how differently map these languages the
Automation (COM) interface...

VBScript:
---------
project.BeginTransaction Nothing
set rf = project.RootFolder

set mrf       = rf.MetaFolder
set f_meta = mrf.LegalChildFolderByName( "MyFolderKind")

set nf        = rf.CreateFolder( f_meta)
nf.Name = "NewFolderOfType_MyFolderKind"

project.CommitTransaction


Python:
-------
project.BeginTransaction( project.CreateTerritory( None, None, None), 0)

metaproj = project.RootMeta		# an IMgaMetaProject
metaroot = metaproj.RootFolder		# an IMgaMetaFolder
	
mfco = metaroot.DefinedFCOByName("MyFCOKind", 1)

nfco = project.RootFolder.CreateRootObject( mfco)
nfco.Name = "NewFCOHurray"

project.CommitTransaction()


If you'd like to have a python app which creates the project (as opposed
to the examples above which can operate from the Console window and
benefit from the existance of the predefined 'project' variable) you
would need to use the following statements first:

import win32com.client
import pythoncom

My_project = win32com.client.Dispatch("Mga.MgaProject")
My_project.Create( "MGA=myfile.mga", "MyParadigmName")

##########
# copy the operations from the codesnippet above
# replacing references from project to My_project

# save the project
My_project.Save()
My_project.Close(0)


To do the same in VBScript:

Set My_Project = CreateObject( "Mga.MgaProject")
My_Project.Open "MGA=myfile.mga"
'
' do my operations
'
My_Project.Close



Zoli

> -----Original Message-----
> From: Paulo Asterio de Castro Guerra 
> [mailto:paulo.asterio.guerra at gmail.com] 
> Sent: Thursday, December 14, 2006 8:00 AM
> To: Zoltan Molnar
> Cc: gme-users
> Subject: Re: [gme-users] JScript Resources
> 
> 
> Hi Zoltan,
> 
> Thanks for the information. Do you have any working example 
> of a JScript that creates a simple model ?
> 
> []s
> 
> Paulo Asterio
> 
> 
> 2006/12/13, Zoltan Molnar <zolmol at isis.vanderbilt.edu>:
> > 3 variables defined for scripting in the console window.
> > gme, project, it.
> > Gme implements IGMEOLEApp, it is creatable by "GME.Application" 
> > progid. Project implements IMgaProject, it is creatable by 
> > "Mga.MgaProject" progid. It implements IGMEOLEIt, not creatable, 
> > represents the active view.
> >
> > The "GME.Application" and "Mga.MgaProject" objects, since they are 
> > creatable can also be used from standalone scripts (like 
> Jscript). For 
> > the Interface definitions please take a look on the idl files in 
> > GME\Interfaces directory (gme.idl, mga.idl).
> >
> > Zoli
> >
> > > -----Original Message-----
> > > From: gme-users-bounces at list.isis.vanderbilt.edu
> > > [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of 
> > > Paulo Asterio de Castro Guerra
> > > Sent: Wednesday, December 13, 2006 1:09 PM
> > > To: gme-users
> > > Subject: [gme-users] JScript Resources
> > >
> > >
> > > Hi,
> > >
> > > Where can I find resources (API documentation, sample code,
> > > ...) about GME scripting using JScript ?
> > >
> > > []s
> > >
> > > Paulo Asterio _______________________________________________
> > > 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