Ask Your Question
1

Add kneepoint to a branch object

asked 2025-08-25 03:32:58 -0500

anonymous user

Anonymous

updated 2025-08-27 02:28:08 -0500

I’m trying to create a schematic using the Python API and the sliderPy module to draw some *.drw files in version 35. I want the drawn elements to be linked to the electrical components, which I’ve managed to achieve using the SetMapString method.

To make the schematic clearer, I need to add knee points to the branch symbols. However, there doesn’t seem to be a CreateKneePoint method for branch symbols. I’ve been able to add them using links, but in that case the links aren’t associated with the electrical elements. How can I add knee points while keeping the connection to the electrical elements? Now the branch symbols are straight lines from node to node.

This is how I use to draw the branch objects. I retrieve the ports using the GetFirstUnlinkedPort method.

doc = sliderPy.GetActiveDocument()
diagram = doc.GetDiagram()
branch = diagram.CreateBranchSymbol(sliderPy.PsseSymbolDefID.Branch, port1, port2)
branch.SetMapString(f"LI {bus_id_1:6d} {bus_id_2:6d} {line_id} ")
edit retag flag offensive close merge delete

Comments

Just to know, how do you usually draw branch symbols? Can you share some example code? I’ve only used sliderpy to click and retrieve/adjust data in the case, but not for automatic drawing, so I don’t know the common way to do it.

jbarberia gravatar imagejbarberia ( 2025-08-26 18:17:49 -0500 )edit

This is how I do it, but I can't figure how to "split" the branch object ``` doc = sliderPy.GetActiveDocument() diagram = doc.GetDiagram() branch = diagram.CreateBranchSymbol(sliderPy.PsseSymbolDefID.Branch, port1, port2) branch.SetMapString(f"LI {bus_id_1:6d} {bus_id_2:6d} {line_id} ") ``

branchseeker gravatar imagebranchseeker ( 2025-08-27 02:25:53 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2025-09-12 20:39:05 -0500

jbarberia gravatar image

Working with sliderPy can be quite tricky — the API is very thin, the documentation only shows raw method signatures, and I learned that you have to manually cast between SldComponent, SldSymbol, SldBranch, and SldLink to get what you need.

The approach I found that works is:

Start with a generic SldComponent, cast it step by step to SldSymbol and then to SldBranch so you can access its network links (at this point branch should be an SldBranch).

Pick one of the two links, cast it to SldLink, create a SldPoint at the desired coordinates, and finally call diagram.CreateKneePoint() to insert a new knee point on that link.

component                           # Sld component
symbol = component.SldSymbol()      # Cast SldComponent -> SldSymbol
branch = symbol.SldBranch()         # Cast SldSymbol    -> SldBranch
links  = branch.GetLinks()          # Gets 2 links to from and to bus ports
link0  = links[0].SldLink()         # Cast SldComponent -> SldSymbol

x, y = 1, 0
point = sliderPy.SldPoint(x, y)     # Position to add the kneepoint
kneepoint = diagram.CreateKneePoint(point, link0)
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

1 follower

Stats

Asked: 2025-08-25 03:32:58 -0500

Seen: 70 times

Last updated: 20 hours ago