PowerFactory Scripter: Legacy Form
Fill in a form, get a ready-to-run PowerFactory script.
← Other Tools
⏳ Loading DB…
Copied to clipboard!
Code generated!
JSON imported!
Function inserted!

Validation Errors

    Warnings

      This is the original form. For your own study sequence, wire study blocks in the PowerFactory Workflow Builder.
      💡 New here? Browse the Samples & Guides to see worked examples before configuring your script.
      Quick Start with IEEE 9-bus System

      Initialisation

      ▾

      Input Variables

      ▾
      Set PowerFactory object parameters before each simulation. Enter the object using its PF path and class (e.g. Gen.ElmSym) and the parameter to modify (e.g. e:qgini).
      GetCalcRelevantObjects() resolves the object query; SetAttribute() writes the value before each run.
      Brute Force: Step Size is the increment (not number of steps); every combination is iterated.
      Integer / on-off attributes (modes, flags, tap positions) have no step: choose Range (Lower to Upper; blank = 0 and 1) or List (e.g. 0,1,5) in the Step cell. This is set from the attribute; the int toggle in the Attribute cell switches it for custom attributes.
      Optimisation: Bounds define the search space; step is unused.
      Custom: Values come from a scenario Excel file (bounds and step are unused).
      Wildcards (e.g. *.ElmDsl) match multiple objects — the same value is applied to all matched objects.
      # Name ? Object ? Attribute ? Lower
      Bound
      Upper
      Bound
      Step
      Size
      ?

      Custom Mode Config

      ▾
      Excel scenario file with a 3-row header (Variable name / Object / Attribute) + one data row per scenario.
      Row 1 — Variable name: label cell Variable name, then one name per column.
      Row 2 — Object: label cell Object, then PF query per column (e.g. Grid.ElmTerm).
      Row 3 — Attribute: label cell Attribute, then attribute name per column.
      Rows 4+ — Data: first cell = scenario label, then numeric values.
      Wildcard queries (e.g. *.ElmSym) apply the value to all matched objects simultaneously. Sheet name must be Sheet1.

      Contingency Config

      ▾
      Specify one or more wildcard element queries. The script resolves all matching objects at runtime, then iterates through each contingency (N-1: one element tripped; N-2: two elements tripped simultaneously). A base case (all in service) is always included as the first run.
      Element Query: wildcard PF query (e.g. *.ElmLne, *.ElmSym).
      Filter Attribute: optional attribute to filter resolved objects (e.g. e:Unom, loc_name).
      Filter Value: numeric (e.g. 66), plain string, or wildcard string (e.g. North* — case-insensitive glob).
      N-2 / Combine: when unchecked, pairs are formed within each element type only (line × line, generator × generator). When checked, pairs cross element types too.
      The outserv attribute (1 = out, 0 = in) is always used and restored in a finally block after each run.
      # Element Query ? Filter Attribute ? Op Filter Value ?

      Output Variables

      ▾
      Read results from PowerFactory after each simulation. Scalar reads a single value from any object; Timeseries captures a signal over time (dynamic studies only); Custom lets you write your own Python calculation.
      Scalar uses obj.GetAttribute() on static result variables (e.g. m:u1, c:loading) after solving — check the PF result variable browser for available keys.
      Timeseries requires a Dynamic RMS or EMT study type. Use the PF variable key (e.g. m:u1, m:I:bus1) — same as the result variable browser, not the descriptive label.
      Custom Calculation arguments must be names of other defined Input or Output Variables. It must return exactly one scalar, and a value it could not read arrives as None. Pick a ready-made one from Insert a pre-made function above the editor, or see the custom function library.
      All variable names must be unique across inputs and outputs.

      Optimisation Settings

      ▾

      Constraints ?
      Output Variable Operator Value

      Additional Config

      ▾
      ▸ Generated Code Preview
      
      
      ▶ Configure inputs and click Generate Code