How to create a network element with a Python script?
Category:
Scripting
Answer
If a network element is to be added to a project with Python, additional steps must be followed so that the element is also connected and displayed. In the first step, the new network element must be created (in this example, a general load):
network = app.GetCalcRelevantObjects('Grid.ElmNet')[0]
newLoad = network.CreateObject('ElmLod','new_load')
To connect the new element to a terminal, a new cubicle must first be created in the terminal. This cubicle must then be connected to the new network element:
myTerm = app.GetCalcRelevantObjects('Busbar1.ElmTerm')[0]
newCubicle = myTerm.CreateObject('StaCubic','new_cub')
newCubicle.obj_id = newLoad
Finally, the new element can be displayed in existing diagrams. The easiest way to do this is automatically with the diagram layout tool. This can also be configured and executed using Python:
graphic = app.GetDesktop()
graphic.Unfreeze()
comlayout = app.GetFromStudyCase('ComSgllayout')
comlayout.iAction = 1
comlayout.insertionMode = 1
comlayout.Execute()
The attached project contains a script that can be used directly to add a new load to an existing terminal.
Tags