Menu

Python.NET Enum compatibility issue

Andrew L
2021-07-28
2021-07-28
  • Andrew L

    Andrew L - 2021-07-28

    Hello,

    Been a long-time lurker when it comes to DWSIM, but I've been having an issue with Python Unit Operations when used with Python.NET, and have been having trouble eliminating the error.

    Looking at the code in Dan's post for NN along with the reference for the Flowsheet.ShowMessage() method, three parameters are meant to be supplied - a message string, an enumerated integer, and an optional exception. However, when I do this for a flowsheet with a simple unit op (1 input, 1 output), I get the error in the attached screenshot.

    I've tried using the clr.System.Enum class from the pythonnet module, but it's an abstract class and cannot be initialized. I also tried creating my own class with a method returning an integer, decorated by clr.clrproperty(clr.System.Enum). Any ideas on what I can do? Should I revert to an earlier version of pythonnet or DWSIM?

    DWSIM v6.5.5
    Python v3.8.10
    pythonnet v2.5.2

     

    Last edit: Andrew L 2021-07-28
  • Daniel Medeiros

    Daniel Medeiros - 2021-07-28

    Try Flowsheet.WriteMessage(text) instead, it works the same.

     
  • Andrew L

    Andrew L - 2021-07-28

    Thanks for the fast response, Dan. The WriteMessage method works for simple messages. Am I likely to run into other methods (particularly in the EnergyStream and MaterialStream classes) that require passing of Enums from Python into .NET?

     
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.