But I get this error:
NameError: name 'Flowsheet' is not defined
I think both of my questions are really asking how to fully connect my python IDE to DWSIM so I can code simulations outside DWSIM and see the calculated results in my IDE.
Thank you for any solutions to my problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you very much. When doing this I got an error that says:
'InvalidOperationException: The calling thread must be STA, because many UI components require this.
at System.Windows.Input.InputManager..ctor()
at System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
at System.Windows.Input.KeyboardNavigation..ctor()
at System.Windows.FrameworkElement.FrameworkServices..ctor()
at System.Windows.FrameworkElement.EnsureFrameworkServices()
at System.Windows.FrameworkElement..ctor()
at Eto.Wpf.Forms.WpfPanel`3..ctor()
at Eto.Wpf.Forms.FormHandler..ctor()
at Eto.Wpf.Platform.<>c.<addto>b__10_90()
at Eto.Widget..ctor()
at Eto.Forms.Control..ctor()
at Eto.Forms.Window..ctor()
at DWSIM.UI.Forms.Flowsheet..ctor() in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM.UI.Desktop.Forms\Forms\Flowsheet\Flowsheet.cs:line 13
at DWSIM.Automation.Automation2.CreateFlowsheet() in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM.Automation\Interface.cs:line 190</addto>
STA stands for Single Thread Apartment.
So I know each Object listed should be on a single thread and I need to initialize COM library for each thread. But the .Net documentation on Microsoft has all examples in C# do you know how to go about this since im completely lost. Once again thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah okay thank you it worked! Just for anyone watching the thread I'm using this in jupyter notebook so you can use DWSIM in an ipynb. Just One more thing is it possible to code from outside DWSIM and view a screenshot of the flowsheet. So you can see the a picture of the components and streams in your python IDE without opening the simulator itself. Thanks again
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also where is the documentation for python and DWSIM sorry I was struggling to find it on the website. Ive only been able to locate the C# thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code above didnt work in my python IDE but I think you can connect python and VB.NET so I will try that and when I find a solution I will post it on here, but thank you for your help
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes it worked! Thank you for being extremely helpful! Hopefully this will help others aswell! I think I need to have better knowledge of .NET to help me with my customization, but thanks again!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there anyway I can load or create a new simulation from my python IDE.
My second question:
using my python IDE i am trying to control DWSIM so I use this code:
import clr
import sys
import subprocess
clr.AddReference('D:\DWSIM6\DWSIM.Interfaces.dll')
clr.AddReference('D:\DWSIM6\DWSIM.Automation.dll')
clr.AddReference('D:\DWSIM6\DWSIM.Thermodynamics.dll')
clr.AddReference('D:\DWSIM6\DWSIM')
from DWSIM.Thermodynamics import *
from DWSIM import Interfaces
from DWSIM import Automation
from DWSIM import *
cooler = Flowsheet.AddObject(Interfaces.Enums.GraphicObjects.ObjectType.Cooler, 100, 100, 'COOLER-001')
But I get this error:
NameError: name 'Flowsheet' is not defined
I think both of my questions are really asking how to fully connect my python IDE to DWSIM so I can code simulations outside DWSIM and see the calculated results in my IDE.
Thank you for any solutions to my problem.
you need to create the flowsheet from the automation interface.
thank you very much. When doing this I got an error that says:
'InvalidOperationException: The calling thread must be STA, because many UI components require this.
at System.Windows.Input.InputManager..ctor()
at System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
at System.Windows.Input.KeyboardNavigation..ctor()
at System.Windows.FrameworkElement.FrameworkServices..ctor()
at System.Windows.FrameworkElement.EnsureFrameworkServices()
at System.Windows.FrameworkElement..ctor()
at Eto.Wpf.Forms.WpfPanel`3..ctor()
at Eto.Wpf.Forms.FormHandler..ctor()
at Eto.Wpf.Platform.<>c.<addto>b__10_90()
at Eto.Widget..ctor()
at Eto.Forms.Control..ctor()
at Eto.Forms.Window..ctor()
at DWSIM.UI.Forms.Flowsheet..ctor() in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM.UI.Desktop.Forms\Forms\Flowsheet\Flowsheet.cs:line 13
at DWSIM.Automation.Automation2.CreateFlowsheet() in C:\Users\Daniel\source\repos\DanWBR\dwsim6\DWSIM.Automation\Interface.cs:line 190</addto>
STA stands for Single Thread Apartment.
So I know each Object listed should be on a single thread and I need to initialize COM library for each thread. But the .Net documentation on Microsoft has all examples in C# do you know how to go about this since im completely lost. Once again thank you.
Check this: https://gist.github.com/DanWBR/c355fd5420d20d960f5d084a7142cde8
You may have to add
before everything else.
Ah okay thank you it worked! Just for anyone watching the thread I'm using this in jupyter notebook so you can use DWSIM in an ipynb. Just One more thing is it possible to code from outside DWSIM and view a screenshot of the flowsheet. So you can see the a picture of the components and streams in your python IDE without opening the simulator itself. Thanks again
Also where is the documentation for python and DWSIM sorry I was struggling to find it on the website. Ive only been able to locate the C# thanks in advance
You can try this (VB code), but I don't know if it will work on Python:
The "SK" objects are contained in the SkiaSharp.dll assembly. Image comes from System.Drawing.dll
PFDSurface is the PFD drawing area, you can get a reference to it through
Last edit: Daniel Medeiros 2021-01-09
The code above didnt work in my python IDE but I think you can connect python and VB.NET so I will try that and when I find a solution I will post it on here, but thank you for your help
This works (tested):
Yes it worked! Thank you for being extremely helpful! Hopefully this will help others aswell! I think I need to have better knowledge of .NET to help me with my customization, but thanks again!