How can I assign a time characteristic to a generator using Python script?

Category:
Scripting
Answer

Define a variable that contains a generator object and use CreateObject() method on it. It is assumed, that there are already characteristics available in the corresponding subfolder of the operational data library.

Example:

import powerfactory

app=powerfactory.GetApplication()

charFold = app.GetProjectFolder('chars') #get folder, where characteristics are normally stored

chars = charFold.GetContents('*.ChaTime') #get list of all available characteristics

sms = app.GetCalcRelevantObjects('*.ElmSym') #get a list with all generators

for sm in sms: #for each generator

    app.PrintPlain(sm.GetFullName())

    char = sm.CreateObject('ChaRef','pgini') #create a characteristic reference object for a certain parameter

    char.typ_id = chars[0] #link the first (as example) characteristic of the list to the reference object

 

A more detailed example can be found in the Python tutorial, available for registered users in the Download Area under Tutorials->Advanced Tutorials.

Back