Menu

Referring to objects of internal flowsheets

Dmitry
2021-02-12
2021-02-12
  • Dmitry

    Dmitry - 2021-02-12

    Hello, Daniel!

    My flowsheet includes subflowsheet "FS-03" as an element as shown in the screenshot.
    I am trying to get the subflowsheet item as you pointed out in the topic:
    https://sourceforge.net/p/dwsim/discussion/scripting/thread/69416729/

    clr.System.IO.Directory.SetCurrentDirectory(DWSIM_PATH)
    clr.AddReference('Interfaces.dll')
    clr.AddReference('Automation.dll')
    
    process = Automation.Automation()
    process = process.LoadFlowsheet(PATH_TO_FLOWSHEET)
    flowsheet = Interfaces.IFlowsheet(process)
    sim = Automation.Automation()
    
    fs_object = flowsheet.GetFlowsheetSimulationObject('FS-03')
    subfs_object = fs_object.Fsheet
    mstr_object = subfs_object.GetFlowsheetSimulationObject('gMSTR')
    mstr_temperature = mstr_object.GetPropertyValue('PROP_MS_0', None)
    

    But the method GetFlowsheetSimulationObject('FS-03') or GetObject('FS-03') returns None, and fs_object in my case does not contain an attribute Fsheet.

    Also, code

    for objects in flowsheet.SimulationObjects:
        print(objects)
    

    returns a list that does not contain an object "FS-O3"

    1) How can I refer correctly to the subflowsheet, inside the main flowsheet?
    2) I also got stuck on the question: how to get the final value of the spreadsheet cell, which was calculated using the formula inside the spreadsheet?
    Are there any tips or examples?

    Thank you!

     
  • Daniel Medeiros

    Daniel Medeiros - 2021-02-12

    Replace this

    process = Automation.Automation()
    process = process.LoadFlowsheet(PATH_TO_FLOWSHEET)
    flowsheet = Interfaces.IFlowsheet(process)
    sim = Automation.Automation()
    

    by this

    aut = Automation.Automation()
    flowsheet = aut.LoadFlowsheet(PATH_TO_FLOWSHEET)
    
     
  • Dmitry

    Dmitry - 2021-02-12

    Thank you, Daniel!

    As far as I understand, the rest of the code is correct and in this way i can refer to the elements of the subflowsheet?

     
    • Daniel Medeiros

      Daniel Medeiros - 2021-02-12

      I don't see anything wrong, it should work...

       
  • Daniel Medeiros

    Daniel Medeiros - 2021-02-12

    Notice that the object id is FS-03 with a zero, not with an "O".

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.