Menu

Programmatic access

2015-10-06
2015-10-09
  • Jorge D Varela V

    Hi Daniel

    can I obtain programmatic access to obtain information from and manipulate items inside the DWSIM flowsheet document??
    Do you have an example in Visual basic or other program?
    I need get some data (temperature, pressure, etc) of streams or units operation.

    Thanks

     
  • Daniel Medeiros

    Daniel Medeiros - 2015-10-06

    Hi Jorge,

    Yes, there is: https://sourceforge.net/p/dwsim/discussion/scripting/thread/32b4996c/

    The difference here is that you would use the Script Manager, not a Script UO, and get a reference to the flowsheet objects by using Flowsheet.GetFlowsheetObject(tag) where "tag" is the name of the object in the flowsheet.

    Regards
    Daniel

     
  • Jorge D Varela V

    Thanks Daniel

     
  • Luca Finardi

    Luca Finardi - 2015-10-07

    Jorge

    if for instance you have a flowsheet with a pump having tag PUMP-001, a script fragment like:

    import DWSIM
    from Microsoft.MSDN.Samples.GraphicObjects import *
    p = Flowsheet.GetFlowsheetSimulationObject("PUMP-001")
    print dir(p)

    will list all the properties and methods available for this pump (class), so for example you could use the function GetPropertyValue()

    ha = float(p.GetPropertyValue("PROP_PU_0"))*0.102/0.9 # Head in m
    e = p.GetPropertyValue("PROP_PU_1") # efficiency

    and the analogous function SetPropertyValue():

    p.SetPropertyValue("PROP_PU_1", 75) # set pump effcy 75%

    Hope it helps.

    Luca

     

Log in to post a comment.