Page tree
Skip to end of metadata
Go to start of metadata

It is possible to write scripts for AWRDE in something other than Visual Basic such as Python, Perl, C#, etc.  This article describes the setup for Python

AWRDE is a COM automation server and any programming language that can perform as a COM client can be used. This includes most current programming languages such as Python. With Python you will need to install the win32com.client library.  The easiest way to do this is to use pip.

pip install pypiwin32

While this is the minimum setup, if you plan to do significant work in python you want to create the entire type library you will need to run In a command prompt...

cd [python lib directory]/site-packages/win32com/client

If you run this with the -v option it will indicate the name of the generated python file in case you want to look at it.  These definitions will be loaded automatically when you connect to AWRDE.

Testing your installation

Here is a very simple python program that connects to AWRDE and writes out all the models in the software:

# Simple script to test interface to AWRDE
import win32com.client
awrde = win32com.client.Dispatch('MWOApp.MWOffice')  # connect to AWRDE, load AWRDE types
# create shorthand variable to access AWRDE constants
awrc = win32com.client.constants
# test that type library is loaded
assert awrc.mwEMS_AwrAxiem64 == 2
for model in awrde.Models:

Connecting to a Specific Instance of AWRDE

First in MWO you need to go into the VB scripting and run

Sub Main
   Debug.Print MWOffice.InstanceCLSID
End Sub

to get the CLSID of the instance you want to connect to. This will be something like:


Then, from within python you use:

mport win32com.client
obj = win32com.client.Dispatch("{CLSID}")

where you replace CLSID with the id you want to use.

For example

obj2 = win32com.client.Dispatch("{62F49D56-070F-4E6C-8AB9-25845CB94B9A}")

Note the braces are required