question

rub avatar image
0 Likes"
rub asked Jason Lightfoot commented

Calling python script (not located in the same directory as the model)

Hello everyone. I am trying to call a python script from flexsim. The idea is getting some data from that python script and use it then in flexsim. What I want to do is to call it without being in the same directory as the model, meaning in an specific directory. Is it possible? Thanks in advance.

FlexSim 23.2.2
python connection with flexsim
· 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.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

Add an empty text file to the directory containing your python module/script and name it __init__.py

In your model directory create a symbolic link to the directory containing your script. For example I put my 'central' python script in FlexSim's libraries folder and then ran this in the model folder via a command prompt:

  1. mklink /D FlexSimLibs "C:/Program Files/FlexSim 2023/libraries"

Then the external python is set up using something like:

  1. /**external python: */ /**/"FlexSimLibs.myPythonModule"/**/
  2. /** \nfunction name:*/ /**/"myPythonFunction"/**/

where FlexSimLibs is the name of the symbolic link.

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