How can I execute DPL script via Python?

Category:
Scripting
Answer

For Python, a PowerFactory DPL script (ComDPL) is an object as any other Com* objects (e.g. ComLdf- LoadFlow or ComShc-ShortCircuit,…). You just have to define a variable that represents the ComDpl object and call Execute().

Example:

import powerfactory

app=powerfactory.GetApplication()

PythonScript=app.GetCurrentScript()

#-----------if the ComDpl is saved on the same location as ComPython-------------------

FolderOfPythonScript=PythonScript.GetParent()

DPLScript= FolderOfPythonScript.GetContents('DplToExecute.ComDpl',1)[0]

DPLScript.Execute()

Back