Starting a flexsim simulation model from python

Starting a flexsim simulation model from python

Hanifi_Yilmaz
Not applicable
81 Views
4 Replies
Message 1 of 5

Starting a flexsim simulation model from python

Hanifi_Yilmaz
Not applicable

[ FlexSim 22.2.4 ]

Hello community,

i am dealing with the problem to start flexsim from python and exchange values between python and the model. My goal is to extend a metaheuristic with flexsim to solve a combinatorical problem. I found out that there is a library called "FlexSimPy" to create the connection. I just followed the steps which are documented here GitHub - flexsim/FlexSimPy: FlexSimPy. I created a Development version, added a treenote with the name of the module as documented in Module SDK Quick Start (flexsim.com) . I opened the FlexSimPy.sln file in visual studio and tried to build the solution.

Now i got the problem, that i dont know how to set the configuration parameters in visual studio. 1677247485188.png

If i set the plattform to x64 in FlexSimPy and the Pyconnector, the solution is built successfully. If i want to run the code which is in it, i got the error "PyConnector39.dll is not a Win32 application". If i try to build the solution when i set the plattform to Win32, i got many errors when i try to build the solution. I use Python 3.9. on my computer.

I dont have any experience with visual studio and the SDK of Flexsim, therefore i cant judge my approach. I hope you can help me to make it work!

@Phil BoBo @anthony.johnson @Matthew Gillespie

Accepted solutions (1)
82 Views
4 Replies
Replies (4)
Message 2 of 5

JordanLJohnson
Autodesk
Autodesk
Accepted solution

Here is my troubleshooting guide:

  1. Verify that the repository you cloned is on the 22.2 branch (to match your software version). If you didn't clone it, but instead downloaded a zip file, be sure to set the Branch to 22.2, and then download the zip file.
  2. Verify that you are building for the x64 platform, and that you are using Rel_3_9. Here is what my configuration looks like. I suspect this is your issue:
    1677518459336.png
  3. Verify that your module development version of FlexSim is set to use Python 3.9. If you followed the instructions to create a module dll, you'll have different prefs for your development version. To check, open Global Preferences in your dev version of FlexSim:
    1655316797450.png
  4. Once you build successfully, make sure you copy all the files from out/FlexSimPy to the same directory as your python script.
  5. If you set the "evaluationLicense" argument in the controller to False, I don't think you can use a debugger. I think you'd have to use print statements or similar.
.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 5

Hanifi_Yilmaz
Not applicable

Hey @Jordan Johnson ,

i followed your instruction but this didnt work out for me. "PyConnector39.dll is not a Win32 application" is the answer i always get from visual studio.

0 Likes
Message 4 of 5

JordanLJohnson
Autodesk
Autodesk
When do you get that error message? Are you pushing the "run" button at the top? If so, what is your startup project? To run the test python script, you need to right-click the TestFlexSimPy project, point to the "Debug" menu, and choose "Start New Instance".
.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 5 of 5

Hanifi_Yilmaz
Not applicable

We solved the problem together with @Jordan Johnson. In the probiertes of Visual Studio the wrong C++ Language was selected. We choosed the latest one and were able to built the Solution successfully. Thank you!

0 Likes