IscDiagram

class ipsa.IscDiagram

The IscDiagram class provides access to graphical data on a single IPSA diagram. These functions allow network components to be drawn, display options to be set and deleted.

The creation of items on the diagram also creates the associated network components. The parameters of these components can then be set using the functions described for the particular component types.

The origin for the co-ordinates is normally the top left corner of the diagram. Positive values of X are to the right whilst positive values of Y are down below the origin.

GetName() str

Returns the name of the diagram.

Returns:

The name of the diagram.

Return type:

str

SetName(strName: str) None

Sets the name of the diagram.

Parameters:

strName (str) – The name of the diagram.

CreateBusbarPoint(strName: str, dX: float, dY: float) int

Creates a new busbar component on the diagram. A point busbar symbol is a small dot which does not resize as the diagram zoom level is changed.

Parameters:
  • strName (str) – The busbar name.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

The unique ID of the new busbar.

Return type:

int

CreateBusbarJunction(strName: str, dX: float, dY: float) int

Creates a new busbar component on the diagram. A junction busbar symbol is the circular junction symbol.

Parameters:
  • strName (str) – The busbar name.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

The unique ID of the new busbar.

Return type:

int

CreateBusbarHexagonal(strName: str, dX: float, dY: float) int

Creates a new busbar component on the diagram. A hexagonal busbar symbol has six sides.

Parameters:
  • strName (str) – The busbar name.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

The unique ID of the new busbar.

Return type:

int

CreateBusbarCircular(strName: str, dX: float, dY: float) int

Creates a new busbar component on the diagram. A circular busbar symbol is a circle.

Parameters:
  • strName (str) – The busbar name.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

The unique ID of the new busbar.

Return type:

int

CreateBusbarRectangular(strName: str, bHorizontal: bool, dX: float, dY: float) int

Creates a new busbar component on the diagram. The rectangular symbol is the standard horizontal or vertical busbar.

Parameters:
  • strName (str) – The busbar name.

  • bHorizontal (bool) – True draws a horizontal rectangular busbar, while False draws a vertical busbar.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

The unique ID of the new busbar.

Return type:

int

DrawBusbarPoint(nUID: int, dX: float, dY: float) bool

Draws an existing busbar component on the diagram as defined by the busbar UID. A point busbar symbol is displayed as a small dot which does not resize as the diagram zoom level is changed.

Parameters:
  • nUID (int) – The busbar UID.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

Boolean denoting whether the busbar was drawn.

Return type:

bool

DrawBusbarJunction(nUID: int, dX: float, dY: float) bool

Draws an existing busbar component on the diagram as defined by the busbar UID. A junction busbar symbol is the solid circular junction symbol.

Parameters:
  • nUID (int) – The busbar UID.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

Boolean denoting whether the busbar was drawn.

Return type:

bool

DrawBusbarHexagonal(nUID: int, dX: float, dY: float) bool

Draws an existing busbar component on the diagram as defined by the busbar UID. The hexagonal symbol is the standard filled hexagonal busbar.

Parameters:
  • nUID (int) – The busbar UID.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

Boolean denoting whether the busbar was drawn.

Return type:

bool

DrawBusbarRectangular(nUID: int, bHorizontal: bool, dSize: float, dX: float, dY: float) bool

Draws an existing busbar component on the diagram as defined by the busbar UID. The rectangular symbol is the standard horizontal or vertical busbar.

Parameters:
  • nUID (int) – The busbar UID.

  • bHorizontal (bool) – True draws a horizontal rectangular busbar, while False draws a vertical busbar.

  • dSize (float) – The length of the busbar symbol.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

Boolean denoting whether the busbar was drawn.

Return type:

bool

DrawBusbarCircular(nUID: int, dSize: float, dX: float, dY: float) bool

Draws an existing busbar component on the diagram as defined by the busbar UID. The circular symbol is the larger unfilled circle.

Parameters:
  • nUID (int) – The busbar UID.

  • dSize (float) – The radius of the busbar symbol.

  • dX (float) – The busbar x coordinate.

  • dY (float) – The busbar y coordinate.

Returns:

Boolean denoting whether the busbar was drawn.

Return type:

bool

CreateLine(strName: str, dXFrom: float, dYFrom: float, dXTo: float, dYTo: float) int

Creates a new branch component on the diagram.

Parameters:
  • strName (str) – The branch name.

  • dXFrom (float) – The x coordinate of the busbar where the branch starts.

  • dYFrom (float) – The y coordinate of the busbar where the branch starts.

  • dXTo (float) – The x coordinate of the busbar where the branch ends.

  • dYTo (float) – The y coordinate of the busbar where the branch ends.

Returns:

The unique positive ID of the new branch. A negative value is returned if the “from” end busbar is not found, and zero is returned if the “to” end busbar is not found.

Return type:

int

DrawLine(nUID: int) bool

Draws the symbol for the line identified by the unique ID. The line is drawn as a single segment between two busbars. The line must have been created using one of the following first:

  • IscDiagram.CreateLine

  • IscNetwork.CreateBranch

  • IscNetwork.CreateTransformer

Parameters:

nUID (int) – The line UID.

Returns:

Boolean denoting whether the line was drawn.

Return type:

bool

CreateBreaker(strName: str, dX: float, dY: float) int

Creates a new circuit breaker on the diagram. Note branch has to have already been drawn.

Parameters:
  • strName (str) – The breaker name.

  • dX (float) – The x coordinate of the circuit breaker.

  • dY (float) – The y coordinate of the circuit breaker.

Returns:

The unique positive ID of the new circuit breaker. If the breaker cannot be drawn, the return value is 0.

Return type:

int

DrawBreaker(nBreakerUID: int, dX: float, dY: float) bool

Draws the symbol for the breaker identified by the unique ID nBreakerUID at the location dX,dY.

Parameters:
  • nBreakerUID (int) – The breaker UID.

  • dX (float) – The x coordinate of the circuit breaker.

  • dY (float) – The y coordinate of the circuit breaker.

Returns:

The function returns True if the breaker was drawn

Return type:

bool

CreateTransformer(strName: str, dXFrom: float, dYFrom: float, dXTo: float, dYTo: float) int

Creates a new transformer component on the diagram.

Parameters:
  • strName (str) – The branch name.

  • dXFrom (float) – The x coordinate of the busbar where the branch starts.

  • dYFrom (float) – The y coordinate of the busbar where the branch starts.

  • dXTo (float) – The x coordinate of the busbar where the branch ends.

  • dYTo (float) – The y coordinate of the busbar where the branch ends.

Returns:

The unique positive ID of the new transformer. A negative value is returned if the “from” end busbar is not found, and zero is returned if the “to” end busbar is not found.

Return type:

int

DrawTransformer(nUID: int) bool

Draws the symbol for the transformer identified by the unique ID. The line is drawn as a single segment between two busbars. The line must have been created using the following first:

  • IscNetwork.CreateTransformer

Parameters:

nUID (int) – The transformer UID.

Returns:

Boolean denoting whether the line was drawn.

Return type:

bool

CreateUnbalancedLine(strName: str, dXFrom: float, dYFrom: float, dXTo: float, dYTo: float) int

Creates a new unbalanced line component on the diagram.

Parameters:
  • strName (str) – The unbalanced line name.

  • dXFrom (float) – The x coordinate of the busbar where the branch starts.

  • dYFrom (float) – The y coordinate of the busbar where the branch starts.

  • dXTo (float) – The x coordinate of the busbar where the branch ends.

  • dYTo (float) – The y coordinate of the busbar where the branch ends.

Returns:

The unique positive ID of the new unbalanced line component. A negative value is returned if the “from” end busbar is not found, and zero is returned if the “to” end busbar is not found.

Return type:

int

CreateUnbalancedTransformer(strName: str, dXFrom: float, dYFrom: float, dXTo: float, dYTo: float) int

Creates a new unbalanced transformer component on the diagram.

Parameters:
  • strName (str) – The unbalanced transformer name.

  • dXFrom (float) – The x coordinate of the busbar where the branch starts.

  • dYFrom (float) – The y coordinate of the busbar where the branch starts.

  • dXTo (float) – The x coordinate of the busbar where the branch ends.

  • dYTo (float) – The y coordinate of the busbar where the branch ends.

Returns:

The unique positive ID of the new unbalanced transformer component. A negative value is returned if the “from” end busbar is not found, and zero is returned if the “to” end busbar is not found.

Return type:

int

AddPointToLine(nLineUID: int, dX: float, dY: float, bFromEnd: bool) bool

Adds a knee point to the line identified by the unique ID.

Parameters:
  • nLineUID (int) – The line UID.

  • dX (float) – The knee point x coordinate.

  • dY (float) – The knee point y coordinate.

  • bFromEnd (float) – If True then the knee point is added to the last segment, i.e. furthest from the From end. If False then the knee point is added to the first segment.

Returns:

Boolean denoting whether the knee point was added.

Return type:

bool

RefreshLine(nLineUID: int) None

Redraws the line identified by the line UID after knee points have been added.

Parameters:

nLineUID (int) – The line UID.

SplitBranch(nLineUID: int, nSection: int, dRatio: float, strName: str) int

Splits a branch into two sections connected by a new busbar.

Parameters:
  • nLineUID (int) – The line UID.

  • nSection (int) – Specifies which section of a multi-section branch is split. For branches with only one section then nSection should be set to 0.

  • dRatio (float) – Specifies how the branch impedances are divided between the new branches. A value of 0.0 sets the split position to be at the “From” end whilst a value of 1.0 specifies the “To” end. Values between 0.0 and 1.0 split the branch in proportion. For multi-section branches dRatio splits the section identified by nSection.

  • strName (str) – The name of the busbar.

Returns:

The UID of the new branch if it is greater than 0. ) if the branch has not been split. This is because there is a circuit breaker on the branch or the branch is drawn on more than one diagram.

Return type:

int

DrawUndrawnItemsAttachedToBusbar(nBusbarUID: int) None

Draws items attached to the busbar identified by the busbar UID if they are not already drawn on the diagram. Note that this will draw branch items as well.

Parameters:

nBusbarUID (int) – The busbar UID.

DeleteItem(nUID: int) bool

Deletes the graphic item identified by the UID. This may be a line, radial component or busbar.

Parameters:

nUID (int) – The graphical item UID.

Returns:

True if deletion is successful.

Return type:

bool

GetLineLength(nUID: int) float
GetLineLength(pComponent) float

Returns the component length for the graphic symbol on the current diagram. On geographic diagrams this function returns the actual line length, assuming that the diagram is correctly scaled.

Parameters:
  • nUID (int) – The line UID.

  • pComponent (IscBranch) – The line IscBranch instance.

Returns:

The component length for the graphic symbol.

Return type:

float

SetItemPenColour(nUID: int, nRed: int, nGreen: int, nBlue: int, nAlpha: int) bool

Sets the outline colour of the diagram object. The colour is set by the RGB parameters. All colour parameters should be between 0 and 255.

Parameters:
  • nUID (int) – The diagram object UID.

  • nRed (int) – The red colour.

  • nGreen (int) – The green colour.

  • nBlue (int) – The blue colour.

  • nAlpha (int) – The transparency of the colour.

Returns:

Denoting whether the colour is set.

Return type:

bool

SetItemBrushColour(nUID: int, nRed: int, nGreen: int, nBlue: int, nAlpha: int) bool

Sets the fill colour of the diagram object. The colour is set by the RGB parameters. All colour parameters should be between 0 and 255.

Parameters:
  • nUID (int) – The diagram object UID.

  • nRed (int) – The red colour.

  • nGreen (int) – The green colour.

  • nBlue (int) – The blue colour.

  • nAlpha (int) – The transparency of the colour.

Returns:

Denoting whether the colour is set.

Return type:

bool

MapToLatLong(fScreenX: float, fScreenY: float) List[float]

Returns the latitude and longitude in decimal degrees of the screen position. The diagram is the one referenced by the IscDiagram object that the function is called on. The fScreenX and fScreenY parameters are relative to the nominal centre point of the screen, therefore calling this function with fScreenX = 0.0 and fScreenY = 0.0 returns the centre point of the background map in degrees. Note that the screen X is north/south and screen y is east/west.

Parameters:
  • fScreenX (float) – The x coordinate of the screen position.

  • fScreenX – The y coordinate of the screen position.

Returns:

The latitude and longitude of the screen position.

Return type:

list(float)

LatLongToMap(fN: float, fE: float) List[float]

Returns the screen X and Y coordinates of the latitude and longitude. The fScreenX and fScreenY coordinates are relative to the nominal centre point of the screen which can be found by the MapToLatLong function. Note that the screen X is north/south and screen y is east/west.

Parameters:
  • fN (float) – The latitude.

  • fE (float) – The longitude.

Returns:

The screen X and Y coordinates.

Return type:

list(float)

GetUIDFromCoordinates(dX: float, dY: float) int

Returns the UID of a component at coordinates (dX, dY). The screen coordinates are relative to the nominal centre point of the screen.

Parameters:
  • dX (float) – The screen X coordinate.

  • dY (float) – The screen Y coordinate.

Returns:

The UID of the component located. Returns 0, if the component cannot be found,

Return type:

int

GetBusbarUIDFromCoordinates(dX: float, dY: float) int

Returns the UID of a busbar at coordinates (dX, dY). The screen coordinates are relative to the nominal centre point of the screen.

Parameters:
  • dX (float) – The screen X coordinate.

  • dY (float) – The screen Y coordinate.

Returns:

The UID of the component located. Returns 0, if the component cannot be found,

Return type:

int

GetItemX(nUID: int) float

Returns the screen X coordinate of the busbar. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:

nUID (int) – The busbar UID.

Returns:

The screen X coordinate.

Return type:

float

GetItemY(nUID: int) float

Returns the screen Y coordinate of the busbar. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:

nUID (int) – The busbar UID.

Returns:

The screen Y coordinate.

Return type:

float

GetItemFromXPoints(nUID: int) List[float]

Returns a list of floats for the screen X coordinates of the FROM busbar point, the middle point of the line and all knee points lying on the branch between these two points. The coordinates are for the FROM end of the line. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:

nUID (int) – The line UID.

Returns:

The screen X coordinates.

Return type:

float

GetItemFromYPoints(nUID: int) List[float]

Returns a list of floats for the screen Y coordinates of the FROM busbar point, the middle point of the line and all knee points lying on the branch between these two points. The coordinates are for the FROM end of the line. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:

nUID (int) – The line UID.

Returns:

The screen Y coordinates.

Return type:

float

GetItemToXPoints(nUID: int) List[float]

Returns a list of floats for the screen X coordinates of the TO busbar point, the middle point of the line and all knee points lying on the branch between these two points. The coordinates are for the TO end of the line. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:

nUID (int) – The line UID.

Returns:

The screen X coordinates.

Return type:

float

GetItemToYPoints(nUID: int) List[float]

Returns a list of floats for the screen Y coordinates of the TO busbar point, the middle point of the line and all knee points lying on the branch between these two points. The coordinates are for the TO end of the line. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:

nUID (int) – The line UID.

Returns:

The screen Y coordinates.

Return type:

float

CreateAnnotation(strName: str, strAnnotationText: str, dX: float, dY: float) int

Creates a new diagram annotation. The screen coordinates are relative to the nominal centre point of the screen.

Parameters:
  • strName (str) – The strName is not used and can be an empty string.

  • strAnnotationText (str) – The text to be displayed on the diagram. The text string can include simple html for text formatting.

  • dX (float) – The x coordinate of the diagram.

  • dY (float) – The y coordinate of the diagram.

Returns:

The diagram annotation.

Return type:

int

PrintPDF(strFileName: str) None

Print the diagram to a PDF file.

Parameters:

nUID (int) – The line UID.

Returns:

The screen Y coordinate.

Return type:

float