1
Automation Interface, Add-Ins and Tools / Re: Automation using Python?
« on: March 14, 2011, 08:00:59 am »
It is actually quite straight forward.
You have to get and install the pywin package for the python version you use (me its py2.6)
With that , the EA API is wrapped and becomes available "by magic".
The following is a starter snippet for a python app that connects to an open EA model. To use it, you have to manually open a model and than execute your script. All EA API is available!
Writing EA plug-ins in python also works, but is a different story...
Have fun...
fginfrance
You have to get and install the pywin package for the python version you use (me its py2.6)
With that , the EA API is wrapped and becomes available "by magic".
The following is a starter snippet for a python app that connects to an open EA model. To use it, you have to manually open a model and than execute your script. All EA API is available!
Writing EA plug-ins in python also works, but is a different story...
Have fun...
Code: [Select]
import win32com.client
try:
eaApp = win32com.client.Dispatch("EA.App")
except:
sys.stderr.write( "Unable to connect to EA\n" )
exit()
# from here onwards, the full EA API is available as python objects
# so we can
mEaRep = eaApp.Repository
if mEaRep.ConnectionString == '':
sys.stderr.write( "EA has no Model loaded\n" )
exit()
else:
print "connecting...", self.mEaRep.ConnectionString
fginfrance