question

Hanifi.Yilmaz avatar image
1 Like"
Hanifi.Yilmaz asked Hanifi.Yilmaz commented

Starting a flexsim simulation model from python

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

FlexSim 22.2.4
interaction between flexsim and python
1677247485188.png (20.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Hanifi.Yilmaz commented

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.

1677518459336.png (56.3 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Hanifi.Yilmaz avatar image Hanifi.Yilmaz commented ·

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 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Hanifi.Yilmaz commented ·
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".
0 Likes 0 ·
Hanifi.Yilmaz avatar image Hanifi.Yilmaz commented ·

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 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.