Jump to content
  • 0

Run PowerFactory with Python Script



I'm running initial calculation and RMS simulation in my script and want to get the active power and reactive power coming from the ElmXNet element. I have following lines in my script to retrieve the data:

# Get the ElmXnet element
xnet = app.GetCalcRelevantObjects('External Grid.ElmXnet')
p = xnet.GetAttribute('c:pl')

and I'm getting this error:

AttributeError: 'DataObject' object has no attribute 'c:pl'

wondering if anyone can help me with that and let me know what attribute I should call for this purpose. I've tried pl, p, c:p:bus1 as well and get the similar error.


Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

import sys

sys.path.append(r'C:\\Program Files\\DIgSILENT\\PowerFactory 2023 SP2\\Python\\3.11')

if __name__ == "__main__":
    import powerfactory as pf
    app = pf.GetApplication()
    if app is None:
        raise Exception('Getting PowerFactory application failed')
# Project name and study case
projName = 'Camden Substation'
study_case = 'Consolidated ckts'

# Activate project
project = app.ActivateProject(projName)
proj = app.GetActiveProject()

# Get the study case folder and activate project
oFolder_studycase = app.GetProjectFolder('study')
oCase = oFolder_studycase.GetContents(study_case)[0]

# Get the elmXNet object
elmXNet = app.GetCalcRelevantObjects('External Grid.elmXNet')

# Get the elmRes object
p = elmXNet.GetAttribute('c:pl')


This's what I'm running on PF 2023 SP2. Hope I understood your question well!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...