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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


Is it possible to write scripts for AWRDE in something other than Visual Basic?


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 Perl or Python. With Python you will need to install the win32com.client extension which is available at:

Python Download

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

               ## This is a very simple python script that connects to AWRDE and
                ## dumps out the complete list of models                
                ## win32com.client is required for this script to run.  this is
                ## available from:
                import win32com.client
                for model in awrde.Models:

The same thing can be done from Perl using Perl's COM support. Here is the Perl code to do the same thing:

                use Win32::OLE qw(in with); # make sure to include (in & with)
                # Create an instance of Microwave office and make it visible
                my $MWOffice = Win32::OLE->new('MWOApp.MWOffice')
                or die "couldnt' create";
                $MWOffice->{Visible} = True;
                # Get a list of models and print them to stdout.
                my $Models = $MWOffice->Models();
                foreach my $Model (in $Models)
                print $Model->{Name}, "\n";

Note that the string "MWOApp.MWOffice" will connect to the latest version of the AWRDE you have installed. You can also use "AWR.MWOffice" to get to the latest version or "AWR.MWOffice.7.5" to connect specifically to version 7.5, "AWR.MWOffice.8.0" to connect specifically to version 8.0, etc.

You can also connect to a specific instance of Microwave Office (if you have more than one running) by connecting to the CLSID instead of to the general "MWOApp.MWOffice"

Code Snippets

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.

  • No labels