How can I access all operation scenarios in my project, activate them one by one and do some calculation?

Category:
Scripting
Answer

To access an Folder inside of your PowerFactory project you can use GetProjectFolder() method. As input to this method you can just write type of the Folder you would like to access (e.g. ‘scen’ folder where Operation Scenarios are saved, or ‘study’ for folder of Study Case, or ‘script’ for Scripts,… more information on the User Manual). After accessing the folder use GetChildren() or GetContents() to get list of all objects contained inside of the folder. Loop through the list and activate each operational scenario by using Activate().

Example:

import powerfactory          

app=powerfactory.GetApplication()

Ldf=app.GetFromStudyCase('ComLdf')

FoldOperScens=app.GetProjectFolder('scen')

for OperScen in FoldOperScens.GetChildren(1)[0]:

   OperScen.Activate()

   Ldf.Execute()

   app.PrintPlain(i)

Back