question

David Wang avatar image
0 Likes"
David Wang asked Kavika F commented

How to set up FlexSimPy ?

I am trying to set up FlexSimPy. I got the same problem just like his.Starting a flexsim simulation model from python I followed the instruction but this didn't work out for me.I have also chose the latest C++ version. My Flexsim version is 23.0.10. So I cloned version 23.0 of FlexSimPy.1694584866739.png

I still got the error PyConnector310.dll is not a Win32 application.1694585068238.png

This is what my configuration looks like.1694584687848.png

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


FlexSim 23.0.10
flexsimpyinteraction between flexsim and python
1694584687848.png (21.5 KiB)
1694584866739.png (36.6 KiB)
1694585068238.png (11.8 KiB)
· 2
5 |100000

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

Kavika F avatar image Kavika F ♦ commented ·
Hey @David Wang, what steps are you taking to get this error? Does this happen after building the solution and trying to open FlexSim?
0 Likes 0 ·
David Wang avatar image David Wang Kavika F ♦ commented ·

The problem was at Step5 of build instructions. When I press the build solution button in Visual Studio. The error PyConnector310.dll is not a Win32 application will pop out.

0 Likes 0 ·
img-7044.jpeg (310.4 KiB)

1 Answer

·
Kavika F avatar image
1 Like"
Kavika F answered Kavika F commented

Hey @David Wang, after some troubleshooting, it seems that you're trying to Run/Debug the solution. If you read the bullet points under step 5, it gives you the proper use-cases for what to do after building.

1694635505389.png


1694635505389.png (38.3 KiB)
· 5
5 |100000

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

David Wang avatar image David Wang commented ·

I tried those cases, it doesn't work for me.

First case when I run the script from How to use Flexscript (Python) to create the data into global table Flexsim will crash. test.fsmTestScript.py

Picture below is my Global Preference.1694682357005.png

Second case when I run TestFlexsimPy.py it will have a error No module named 'FlexSimPy'.1694682254940.png

So this is why I suspect the problem is at building. I have tried the tips on .DLL is Not A Valid Win32 Application: 5 Ways to Fix it but it still doesn't work.


0 Likes 0 ·
1694682254940.png (167.1 KiB)
1694682357005.png (20.3 KiB)
test.fsm (25.2 KiB)
testscript.py (163 B)
Kavika F avatar image Kavika F ♦ David Wang commented ·

Hey @David Wang, for the first question, I don't know what you mean when you say that FlexSim crashes when you run the script described in the linked post. I just downloaded the two files talked about in the post (a model and a .py file) and ran them. I had to change the script file name in the "generateData" function to lowercase because that's what it downloaded as, but otherwise it ran fine - no crashing. Do you have any steps to reproduce the crash you're experiencing?

1694731307541.png

If you built the FlexSimPy module correctly from the module folder of your Module Development version of FlexSim, then your PyConnector310.dll should have a newer modified date than the others.

1694731371777.png

That will help you identify if you (1) actually build the FlexSimPy.sln and (2) if it worked correctly.

Are you sure your machine is using Python 3.10? You can open a command prompt and type the following command to get a list of python versions installed on your machine.

py -0

1694731712696.png

For the second issue, the error you get is telling you that the python file cannot find the module specified. The module was built and output into the "FlexSimPy\out\Rel_3_10" file path. There should be 4 files there:

1694732295649.png

You'll want the FlexSimPy.pyd file which is like a .dll file so your python code can find the functions contained in FlexSimPy. Copy it over into the same directory as your TestFlexSimPy.py and it should find it.

If you get a "Fatal Python error" due to GIL complications, follow the fix in this answer.

0 Likes 0 ·
1694731307541.png (15.7 KiB)
1694731371777.png (16.8 KiB)
1694731712696.png (5.7 KiB)
1694732295649.png (12.5 KiB)
David Wang avatar image David Wang Kavika F ♦ commented ·

For the first issue. This is what my crash looks like.I have checked the things you have mentioned but I still can't fix it. My PyConnector310.dll have a newer modified date than the others.1694765697822.png

My python version is 3.10.9.1694765720531.png

For the second issue when I build in Visual Studio. There are only 3 files there. My FlexSimPy.pyd is missing.1694765677524.png

My main goal is to get data from Flexsim in order to train my model dynamically. I found that the Reinforcement Learning in Flexsim uses socket to communicate. Is it possible on my case as well? If it is possible then maybe I will use socket instead of FlexsimPy. And is there any tutorial or example on socket communicate with Flexsim? Thanks!

0 Likes 0 ·
1694765677524.png (74.8 KiB)
1694765697822.png (74.6 KiB)
1694765720531.png (1.1 KiB)
Show more comments

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.