Ask Your Question

Move buses in slider diagrams

asked 2012-01-20 02:48:25 -0500

jtrain gravatar image

Is it possible to move points on a slider diagram using Python? I want to have my slider diagram automatically created for me.

The grow bus functionality draws them in such a mess!

edit retag flag offensive close merge delete



I haven't seen anything helpful, anyone else have some clues here?

JervisW gravatar imageJervisW ( 2012-01-29 06:41:17 -0500 )edit

10 answers

Sort by ยป oldest newest most voted

answered 2012-02-16 19:47:44 -0500

amaity gravatar image

Why would you want to manipulate a slider diagram through python? You could plot your own diagram with matplotlib. That would remove the hassles of searching for the appropriate API (if there are any??). I am trying something similar but struggling to put together some compact bit of code for retrieving the loadflow solution data using the API. Currently I read a text file of the loadflow solution and use it to plot a diagram with matplotlib.

edit flag offensive delete link more


I had almost given up on having buses drawn up and placed the way I wanted. Can you share a bit of the code you are using or a screenshot? This sounds like pretty interesting stuff.

jtrain gravatar imagejtrain ( 2012-02-17 18:07:32 -0500 )edit

answered 2012-02-17 20:14:29 -0500

amaity gravatar image

I must reiterate that my current solution is to work outside PSSE. The solution consists of the following steps:

  1. Take a load flow solution in txt format.
  2. Run a re script through the txt file to separate generation, load and line flow data.
  3. Fix co-ordinates of all buses according to your paper space.
  4. Call matplotlib to draw all the connecting lines and labels.

Note: I am not a professional programmer and I an not sure that this is easier to do than manipulating slider diagrams. But this is definitely another way of presenting your load flow results.

edit flag offensive delete link more

answered 2012-02-18 22:10:00 -0500

amaity gravatar image

Now to Steps 1 & 2:

Copy the loadflow solution (bus based reports without wide format output option) from the output bar and save it in text file format.

Read file with a python script and parse using regular expressions as follows:

import numpy as np
import matplotlib.pyplot as plt
import re, string

text_file = open("loadflow.txt", "r")
a =

b = re.sub('\r\n', '', a)
lines = re.split('BUS', b)

genDat = []
for line in lines:
    if'GENERATION', line):
        genDat.append('^\s*(\d{5}).*(?:TO)\s*(\d{5})(?:\s*\S*){2}\s*(\d)\s*([0-9]+(?:\.[0-9]*)?)', line).groups())
genDat = [list(i) for i in genDat]

That bit of code picks all the generation data for me. I use similar bits for extracting the load and line data.

edit flag offensive delete link more


That regex is astounding. This method looks like it would work really well for PSSE version 29. Is that the version you are running? We only recently (as in 6 months ago) converted to version 32. But lots of us still use 29.

jtrain gravatar imagejtrain ( 2012-02-19 04:37:09 -0500 )edit

I don't see why it shouldn't run in v29. I use v32 now. I had to beg my bosses for the update.

amaity gravatar imageamaity ( 2012-02-19 08:41:28 -0500 )edit

answered 2012-02-20 11:11:32 -0500

amaity gravatar image

updated 2012-02-20 19:10:41 -0500

On to the tedious part that is Step 3. This involves mapping the bus number to its abbreviated name, display name and its co-ordinates in the paper space.

rncpg = [51,32] # mapping of bus to position in paper space
parupg = [227,97] 
mthnpg = [247,144] 
mthnrb = [220,155] 

busMark = [
    [45400, rncpg, 'Ranchi(PG)'], # mapping of bus to it abbreviated name and display name
    [45401, parupg, 'Parulia(PG)'],
    [45403, mthnpg, 'Maithon(PG)'],
    [44400, mthnrb, 'MaithonRB'] 

Getting a presentable layout will require a lot of trial and error. A diagram can say more than a thousand words. But getting it right can be a real pain in the ....

edit flag offensive delete link more

answered 2012-02-21 11:29:07 -0500

amaity gravatar image

updated 2012-02-22 04:36:49 -0500

jtrain gravatar image

Now finish it off with a flourish. Generate the plot with your favorite application. Here is one way to do it.

fig = plt.figure()
ax = fig.add_subplot(111)

for bus, (x, y), name in busMark:
    marker = ax.plot(x, y, 'ko')
    plt.text(x, y, name, fontsize=6) 

ax.set_title('load flow plot')

extent = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
fig.savefig("loadflow.png", bbox_inches=extent)

I have limited myself to the bus markings but this should adequate to convey the general procedure. I am sure I am not the only guy working on this diagram problem. Let us know about your ideas.

edit flag offensive delete link more


@amaity I wish that I could give you more upvotes. I love the way that you have taken a problem that we thought was too hard and developed a very practical solution to solve it. There are a lot of engineers out there that would benefit from this.

jtrain gravatar imagejtrain ( 2012-02-22 04:31:36 -0500 )edit

Aah, those numbers, what do they signify? I wish there were more critics tearing down the method and pointing out demerits - like my boss who on being presented with a printout of the load flow plot passed the following comment - 'this no good, buses not in geographical positions'.

amaity gravatar imageamaity ( 2012-02-22 09:17:45 -0500 )edit

I was contemplating a quick left to his jaw when .... this idea bulb starts blinking and .... wait.... that bloke did have something there - why not put the data on a google map? But that I guess will have to wait till I can retrieve the load flow solution through the psse API.

amaity gravatar imageamaity ( 2012-02-22 09:29:18 -0500 )edit

answered 2014-06-16 07:24:45 -0500

MilesH gravatar image

I realize this post is a bit late, but it may help someone. Try using the module. This module is included with your PSSE download. If you contact Siemens PSSE technical support they will provide you with the documentation and some examples of how to use this module. One of the examples shows how to create your own diagram, including how to place a bus in a certain location.

edit flag offensive delete link more


Which version of PSSE is this in and in what directory? I can't find it my PSSE v33.5 install directory.

amaity gravatar imageamaity ( 2014-08-25 09:36:01 -0500 )edit

The module is actually named sliderPy.pyd. I have PSSE v32.2.1 and v33.5.0. This module is located in the PSSBIN folder for both versions.

MilesH gravatar imageMilesH ( 2014-09-04 14:35:58 -0500 )edit

A pyd extension means it's probably a dll file. So how are you using it ??? Can you share the documentation and the example files?

amaity gravatar imageamaity ( 2014-09-04 20:01:33 -0500 )edit

Try this link: \\\files\PTI_Customer\Pietrow\ The examples will show you how to use it, but I am able to import and use SliderPy.pyd like .py and .pyc files.

MilesH gravatar imageMilesH ( 2014-09-05 07:29:44 -0500 )edit

No, your link doesn't work.

amaity gravatar imageamaity ( 2014-09-05 10:34:32 -0500 )edit

answered 2015-05-15 16:34:49 -0500

mbong gravatar image
# encoding: utf-8
# module sliderPy
# no doc

# imports
import Boost.Python as __Boost_Python

# Variables with simple values

ACLineSegment = 0

Arc = 4

Branch = 2
Breaker = 3

Busbar = 1
BusbarSection = 2
BusEventAccessPoint = 24
BusNode = 0
BusNodeLeft = 26
BusShunt = 13

CenterAlign = 0

Circle = 5
CircularBusbar = 20

ConnectionPort = 50
ConnectivityNode = 1
Contour = 11

Dash = 61680
DashDot = 3848
DashDotDot = 61576

DCLine = 12

Disconnector = 12

Dot = 34952

Ellipse = 6

EnergyConsumer = 7

EventAccessPoint = 23

FACTSBranch = 26
FACTSRadial = 27
FACTSSeries = 15
FACTSShunt = 14

FitToPage = 2
FixedShunt = 5

Floater = 4

Fuse = 11

GeneratingUnit = 8
Generic = 0

GNEShunt = 6

Ground = 14
GroundDisconnector = 28

HiddenAlways = 1

Image = 8

InvalidAlignment = 3
InvalidComponentType = 12
InvalidPrintMode = 4
InvalidSymbolDefID = -1
InvalidSymbolType = 7
InvalidVisibility = -1

Jumper = 24

KneePoint = 1

Label = 9

LeftAlign = 1

Line = 2
Link = 3

Load = 2

Machine = 4
ManualDisconnector = 21

MeasurementFloater = 15
MeasurementGeneric = 16

MiddleAbove = 8
MiddleBelow = 9

ModelAccessPoint = 22
MotorDisconnector = 20

MultiPage = 1
MultiTermDLine = 17
MultiTermDLineEnd = 18
MutualCoupling = 29

Node = 5

NullPosition = -1

PieChart = 21

Planning = 3

Polygon = 10
Port1Above = 0
Port1Below = 1
Port2Above = 2
Port2Below = 3

Radial = 3

Rectangle = 7
RectifierInverter = 13
Reporting = 25

RightAlign = 2

SeriesCapacitor = 17
SeriesReactor = 18

ShuntCapacitor = 6
ShuntReactor = 9

Solid = -1

StaticVarCompensator = 22
StationSupply = 23

Substation = 10

Switch = 4

Symbol = 0

ThreeWindTransformer = 19

Transformer = 5
Triangle = 16

TWTransformer = 11

UnspecifiedDiagramType = 0

VisibleAlways = 0

VSCDCLine = 19

Worldview = 2


ZoomDependent = 2

# functions

def ExtractBValue(p_int, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    ExtractBValue( (int)arg1) -> int :
        unsigned long ExtractBValue(unsigned long color)
        Returns the blue component of the specified COLORREF value

        C++ signature :
            unsigned long ExtractBValue(unsigned long)

def ExtractGValue(p_int, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    ExtractGValue( (int)arg1) -> int :
        unsigned long ExtractGValue(unsigned long color)
        Returns the green component of the specified COLORREF value

        C++ signature :
            unsigned long ExtractGValue(unsigned long)

def ExtractRValue(p_int, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    ExtractRValue( (int)arg1) -> int :
        unsigned long ExtractRValue(unsigned long color)
        Returns the red component of the specified COLORREF value

        C++ signature :
            unsigned long ExtractRValue(unsigned long)

def GetActiveDocument(): # real signature unknown; restored from __doc__
    GetActiveDocument() -> SldDocument :
        SldDocument GetActiveDocument()
        Returns the active SldDocument object

        C++ signature :
            class CPyWrapperDoc GetActiveDocument()
    return SldDocument

def GetExportDirectory(): # real signature unknown; restored from __doc__
    GetExportDirectory() -> str :
        string GetExportDirectory()
        Returns the current export file directory

        C++ signature :
            class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > GetExportDirectory()
    return ""

def GetImportDirectory(): # real signature unknown; restored from __doc__
    GetImportDirectory() -> str :
        string GetImportDirectory()
        Returns the current import file directory

        C++ signature :
            class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > GetImportDirectory()
    return ""

def GetImportFile(): # real signature unknown; restored from __doc__
    GetImportFile() -> str :
        string GetImportFile()
        Returns the current import file path

        C++ signature :
            class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > GetImportFile()
    return ""

def RGB(p_int, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    RGB( (int)arg1, (int)arg2, (int)arg3) -> int :
        unsigned long RGB(int r, int g, int b)
        Returns the specified COLORREF value

        C++ signature :
            unsigned long ...
edit flag offensive delete link more


Here is the API. Unfortunately I could not seem to comment in MilesH post, where this should ideally reside

mbong gravatar imagembong ( 2015-05-15 16:36:19 -0500 )edit

answered 2015-05-26 02:42:49 -0500

rimux gravatar image

I have created for myself simple solution for automatic creation of sld diagram containing necessary buses placed in the right places. Save following gif file and change extension from gif to zip, inside there are one excel file and one python file. Excel template is for preparing list of buses containing x and y coordinates for each bus. On "buses" sheet put bus numbers in the cells where approximately they should appear on your sld file. Then run macro "PreapreForPython" (to do that you will probably need to enable Developer tab). than copy-paste from another sheet list of buses into python just after "buses=" line. Than open in psse blank sld and run that python script. All buses will be more or less in right places. Of course this thing could be improved, feel free to do that, just don't forget to put better solution here :)


edit flag offensive delete link more

answered 2019-07-16 15:35:54 -0500

jconto gravatar image

for small number of buses, this code creates a slider within PSSe, though it does not set the proper X,Y coordinates:
Load a case (bus numbering assumes savnw.sav is loaded)
Open a new (blank) diagram
run this code 
def DrawBusesSLD(buslist):
    for i in range(n_buses):

    for i in range(n_buses):
        psspy.growbus(buslist[i][0],buslist[i][1], buslist[i][2])

# main:
         [203, 0, 0],
         [204, 2, 0],         #not drawn due to being a dummy bus in a multisection line
         [205, 2, 2],      
         [206, 0, 2]

edit flag offensive delete link more

answered 2019-07-10 14:50:55 -0500

yptp gravatar image

Hi, Could you share the code again? The link doesn't work now. I am struggling using python to drwa the SLD.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools



Asked: 2012-01-20 02:48:25 -0500

Seen: 4,882 times

Last updated: Jul 16 '19