Menu

python communicating with DWSIM from *outside* of DWSIM

2019-02-16
2020-07-08
<< < 1 2 (Page 2 of 2)
  • Daniel Medeiros

    Daniel Medeiros - 2020-06-20

    Try replacing DWSIM.exe with this one: https://drive.google.com/open?id=1iv3g7bBWsItlDNYYw0iiWA5Sp5aWHmwA

    Then use System.Windows.Forms and System.Drawing from DWSIM app bundle.

     
  • Ryan Stoddard

    Ryan Stoddard - 2020-06-22

    when I replace DWSIM.exe I get the same System.ArgumentNullException: Value cannot be null error as I had previously

     
  • Daniel Medeiros

    Daniel Medeiros - 2020-06-22

    This is simply because mono cannot load the flowsheet form's icon. Even if it is not displayed, I need to create a new instance of the flowsheet, which is a Form... I don't know what else to do.

     
  • Ryan Stoddard

    Ryan Stoddard - 2020-06-22

    is this something that you intend to provide support for? Or is my best bet for using automation with python to remote into a windows machine

     
    • Daniel Medeiros

      Daniel Medeiros - 2020-06-22

      Yes, but I can't give you a release date... I could try working around this mono bug but it is a very time consuming task.

       
  • Ryan Stoddard

    Ryan Stoddard - 2020-06-23

    OK thanks. I am now trying to use automation with python and pythonnet on a windows machine to bypass the Mono issue. Now

    interf = DWSIM.Automation.Automation()

    suceeds but

    sim = interf.LoadFlowsheet("samples/Cavett's Problem.dwxml")

    gives the error below. Do you know the reason for this error? Thanks!

    FileNotFoundException: Could not load file or assembly 'OpenTK, Version=3.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4' or one of its dependencies. The system cannot find the file specified.
    at DWSIM.FlowsheetSurface_SkiaSharp..ctor()
    at DWSIM.FormFlowsheet..ctor() in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM\Forms\Flowsheet\FormFlowsheet.vb:line 75
    at DWSIM.FormMain.LoadXML(String path, Action`1 ProgressFeedBack, String simulationfilename, Boolean forcommandline) in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM\Forms\Main Window\FormMain.vb:line 1573
    at DWSIM.Automation.Automation.LoadFlowsheet(String filepath) in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM.Automation\Interface.cs:line 41

     
    • Daniel Medeiros

      Daniel Medeiros - 2020-06-23

      Did you set the current directory to DWSIM's?

       
  • Ryan Stoddard

    Ryan Stoddard - 2020-06-23

    Yes. I set the directory to directory contialing DWSIM.exe and the dll files using System.IO.Directory.SetCurrentDirectory(). In addition, I tried running the .py script from the same directory with all the dll files and that didn't work either

     
  • Ryan Stoddard

    Ryan Stoddard - 2020-06-29

    Hi Daniel,

    I still have not resolved the above 'OpenTK' error when trying to run DWSIM Automation using pythonnet on windows (from outside of DWSIM). Could you please advise?

    I am wondering if it is a problem on my end or a bug with DWSIM Automation. Are you able to interface with DWSIM using python outside of DWSIM?

    I think others may desire this same functionality. Please advise if it is possible

     
  • Daniel Medeiros

    Daniel Medeiros - 2020-06-29

    Can you share your python code so I can try it from here?

     
  • Ryan Stoddard

    Ryan Stoddard - 2020-06-29

    Thanks for your help. Code below. Running Python 3.6 on Windows 7 with latest DWSIM

    import clr
    import sys
    import System

    sys.path.append('C:/Users/ryan/AppData/Local/DWSIM6')
    System.IO.Directory.SetCurrentDirectory('C:/Users/ryan/AppData/Local/DWSIM6')

    clr.AddReference("System.Core")
    clr.AddReference("System.IO")
    clr.AddReference("System.Collections")
    clr.AddReference("System.Memory")
    clr.AddReference("System.Windows.Forms")

    clr.AddReference('DWSIM')
    clr.AddReference('DWSIM.Automation')
    clr.AddReference('DWSIM.Interfaces')
    clr.AddReference('CapeOpen')

    import DWSIM

    interf = DWSIM.Automation.Automation()

    sim = interf.LoadFlowsheet("samples/Cavett's Problem.dwxml")

     
  • Daniel Medeiros

    Daniel Medeiros - 2020-07-06

    v6.0 Update 5 fixed the automation issue on Windows. Also, automation now works on macOS and Linux through the new Automation2 class. Give it a try and let me know if it works for you.

     
  • Daniel Medeiros

    Daniel Medeiros - 2020-07-06

    I've added a sample project to test automation on macOS to github, which you can run using VS for Mac: https://github.com/DanWBR/DWSIM.Automation.Test.macOS

     
  • Ryan Stoddard

    Ryan Stoddard - 2020-07-08

    Hi Daniel,

    I tested my python code with the v6.0 Update 5 for Windows and automation is now working! Thanks for the update. It seems I can now do everything from python outside of DWSIM which allows for using external python packages.

    I have not had a chance to test the automation on macOS yet, I will reply to this thread if I have a chance to test that

     
<< < 1 2 (Page 2 of 2)
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.