How to set up FlexSimPy ?

How to set up FlexSimPy ?

David111378054
Not applicable
4,469 Views
8 Replies
Message 1 of 9

How to set up FlexSimPy ?

David111378054
Not applicable

[ FlexSim 23.0.10 ]

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!


0 Likes
Accepted solutions (1)
4,470 Views
8 Replies
Replies (8)
Message 2 of 9

kavika_faleumu
Autodesk
Autodesk
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
Message 3 of 9

David111378054
Not applicable

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.73602-img-7044.jpeg

0 Likes
Message 4 of 9

kavika_faleumu
Autodesk
Autodesk
Accepted solution

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

Message 5 of 9

David111378054
Not applicable

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
Message 6 of 9

kavika_faleumu
Autodesk
Autodesk

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
Message 7 of 9

David111378054
Not applicable

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
Message 8 of 9

kavika_faleumu
Autodesk
Autodesk

@David Wang, could you please rebuild your FlexSimPy.sln?1694793793891.png

And let me know what the Output is.

1694793819500.png

In the output, it should tell you that it has created files such as the .lib and .exp, etc.
Make sure that your configuration is Rel_3_10 x64:

1694793959009.png

If you go to the Property Manager, check the General Configuration settings to make sure they're like this:

1694794034919.png

Notice the Output Directory - it specifies that it will output files to a specific directory with the name of the configuration. If you see the screenshot I have above, the .pyd file is there.

I also don't understand how your FlexSim is crashing when running the script. Does it crash when you run those files on a different version of FlexSim (like one that you haven't modified or copied for module development)?

0 Likes
Message 9 of 9

kavika_faleumu
Autodesk
Autodesk
With regards to your question about sockets, yes you can connect to FlexSim using python and sockets. Here are a few examples:

Sockets and the Experimenter

Sockets and Global Tables

Docs with server commands

0 Likes