Scripting Aurora from Visual Studio with Python

NOTE: You do not have to use Visual Studios to script Aurora with Python, you can use another IDE like PyCharm. If you are not using Visual Studios, you can skip to Step 4.

1. Install Python Development to Visual Studios.

2. Create New Python Application Project.

3. Open Python Environment window in Visual Studios and choose or add a Python 3 Environment.

4. Go to Python Environment window and change the dropdown combobox from “Overview” to “PyPi”. This will allow you to install the needed packages.  

5. Search “pythonnet” and click “Run Command: pip install pythonnet”. This will add the “pythonnet” package, which is critical to scripting Aurora with Python. 

6. Open your Python file and add “import clr” to the top. (This is part of the pythonnet package that was just added to the project.)

The following code needs to be added to your script for it to reference Aurora properly. This will import the .dlls needed to access Aurora functions in such a way that a Python script can read and use them.

This example is assuming you are using Aurora 13.5. The dlls location and name can change depending on what version of Aurora you are using.

If using version 13.4 or earlier, use the dlls located here: 
C:\Program Files (x86)\AURORA\AURORA\AURORAMessaging.dll
C:\Program Files (x86)\AURORA\ AURORA\AURORAServer.dll
C:\Program Files (x86)\AURORA\AURORA\EPIS.AURORAxmp.Common.dll
C:\Program Files (x86)\AURORA\AURORA\EPIS.AURORAxmp.Model.dll
C:\Program Files (x86)\AURORA\AURORA\EnergyExemplar.Aurora.ParameterSets.dll

If using version 13.5, use the dlls located here: 
C:\Program Files\Energy Exemplar\Aurora 13.5\AURORAMessaging.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\AURORAServer.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\EPIS.AURORAxmp.Common.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\EPIS.AURORAxmp.Model.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\EnergyExemplar.Aurora.ParameterSets.dll

If using version 14.0, use the dlls located here: 
C:\Program Files\Energy Exemplar\Aurora 14.0\AURORAMessaging.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\AURORAServer.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\EPIS.AURORAxmp.Common.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\EPIS.AURORAxmp.Model.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\EnergyExemplar.Aurora.ParameterSets.dll

If using version 14.1 or later, use the dlls located here (note that the dll names have changed slightly) 
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Messaging.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Server.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Common.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Model.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.ParameterSets.dll

 

import clr

clr.AddReference('C:\\Program Files\\Energy Exemplar\\Aurora 13.5\\AURORAServer.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\Aurora 13.5\\AURORAMessaging.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\Aurora 13.5\\EPIS.AURORAxmp.Common.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\Aurora 13.5\\EPIS.AURORAxmp.Model.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\Aurora 13.5\\EnergyExemplar.Aurora.ParameterSets.dll')

from AURORAServer import *

from AURORAMessaging import *

from EPIS.AURORAxmp.Common import *

from EPIS.AURORAxmp.Model import *

from EnergyExemplar.Aurora.ParameterSets import

 

If using version 14.2 or later, use the dlls located here (note that the dll names have changed slightly) 
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Messaging.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Server.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Common.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Model.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.ParameterSets.dll

 

import clr

clr.AddReference('C:\\Program Files\\Energy Exemplar\\[current version]\\EnergyExemplar.Aurora.Messaging.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\[current version]\\EnergyExemplar.Aurora.Server.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\[current version]\\EnergyExemplar.Aurora.Common.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\[current version]\\EnergyExemplar.Aurora.Model.dll')

clr.AddReference('C:\\Program Files\\Energy Exemplar\\[current version]\\EnergyExemplar.Aurora.ParameterSets.dll')

from EnergyExemplar.Aurora.Messaging import *

from AURORAServer import *

from EnergyExemplar.Aurora.Common import *

from EnergyExemplar.Aurora.Model import *

from EnergyExemplar.Aurora.ParameterSets import *

 

7. Add AC and ADS objects to your Python script.  You also must call AC.InitializeAURORAXMP() before you use any AC functions.

AC = ComApplication()

ADS = ComDataSet()

AC.InitializeAURORAXMP()

 

8. Write your Python script!

NOTE: One important thing to note is the Intellisense cannot read the Aurora dlls that you are using, so the AC and ADS functions will not have autocomplete. You will have to type out AC and ADS function names, like LoadProjectWaitForDBRead, manually.

Scripting

Scripting Aurora from Visual Studio with Python


For further assistance, please contact Aurora Support.

Copyright© 1997-2024 Energy Exemplar LLC. All rights reserved.