Why are my old scripts not working in PowerFactory 2021 and later
In PowerFactory 2021 a new plot framework was introduced. The old classes for pages (SetVipage) and plots (VisPlot, Vis..) were retired and new, more advanced, classes are now avaiable and the new default (GrpPage, PltLinebarplot, Plt...). Thus, old function calling old classes will not work in PowerFactory 2021 and later and scripts have to be adapted in order to use the new plot framework in the long term.
However, in the short term the old plot framework can still be used in order to ensure a smooth transition. The user can change to the old plot framework by deselecting the checkmark "Use new plot framework" on the "Plots" page in the project settings. The old framework will not be maintained and disabled at some point.
Below you find a short example Python script plotting line loadings after a Quasi Dynamic Simulation using the new plot framework:
app = powerfactory.GetApplication()
# Get QDS command and execute it
QDS = app.GetFromStudyCase('ComStatsim')
# Get QDS result file
res = QDS.results
#Get Plot Page from Graphics Board
graphicsBoard = app.GetGraphicsBoard()
plotPage = graphicsBoard.GetPage("MyFirstPlotPage", 1, "GrpPage")
app.PrintPlain("Page used: %s" %plotPage)
curvePlot = plotPage.GetOrInsertCurvePlot("CurvePlot",1)
dataSeries = curvePlot.GetDataSeries()
lines = app.GetCalcRelevantObjects("ElmLne")
# Add variable 'c:loading' for each line
for line in lines:
dataSeries.AddCurve(line, "c:loading", res)
# Get x-Axis and set axis mode to "Date and Time"
xAxis = curvePlot.GetAxisX()
xAxis.axisMode = 2
# Auto-scale x- and y axis