Difference between revisions of "IronPython Script Snippets"
Jump to navigation
Jump to search
(Created page with "= Script Manager Snippet 1: Create and Connect Objects = Assuming that you're running a simulation with defined compound(s) and property package(s), this will create and conn...") |
|||
Line 3: | Line 3: | ||
Assuming that you're running a simulation with defined compound(s) and property package(s), this will create and connect a cooler and its connections: | Assuming that you're running a simulation with defined compound(s) and property package(s), this will create and connect a cooler and its connections: | ||
− | < | + | <source lang=python> |
import clr | import clr | ||
Line 25: | Line 25: | ||
− | </ | + | </source> |
Revision as of 17:17, 2 July 2019
Script Manager Snippet 1: Create and Connect Objects
Assuming that you're running a simulation with defined compound(s) and property package(s), this will create and connect a cooler and its connections:
import clr clr.AddReference('DWSIM.Interfaces') from DWSIM import Interfaces cooler = Flowsheet.AddObject(Interfaces.Enums.GraphicObjects.ObjectType.Cooler, 100, 100, 'COOLER-001') heat_out = Flowsheet.AddObject(Interfaces.Enums.GraphicObjects.ObjectType.EnergyStream, 130, 150, 'HEAT_OUT') inlet = Flowsheet.AddObject(Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream, 50, 100, 'INLET') outlet = Flowsheet.AddObject(Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream, 150, 100, 'OUTLET') cooler.GraphicObject.CreateConnectors(1, 1) inlet.GraphicObject.CreateConnectors(1, 1) outlet.GraphicObject.CreateConnectors(1, 1) heat_out.GraphicObject.CreateConnectors(1, 1) Flowsheet.ConnectObjects(inlet.GraphicObject, cooler.GraphicObject, 0, 0) Flowsheet.ConnectObjects(cooler.GraphicObject, outlet.GraphicObject, 0, 0) Flowsheet.ConnectObjects(cooler.GraphicObject, heat_out.GraphicObject, 0, 0)