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

Category:
Scripting
Answer

To link a time characteristic to the input variable of an element, a ChaRef object with the name of the parameter has to be created in the element. For this, get the element (e.g. a generator object) and use the CreateObject() method on it to create this ChaRef. In this example 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 time 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 Functions" or directly in PowerFactory in "Help > Tutorial... > Advanced Functions".

Back