How I can conect a python file with a flexsim model

How I can conect a python file with a flexsim model

diego_rt
Not applicable
294 Views
7 Replies
Message 1 of 8

How I can conect a python file with a flexsim model

diego_rt
Not applicable

[ FlexSim 23.0.3 ]

Good night,

I have a problem with a FlexSim model. I want to connect a process flow with a Python file, where I have a solution for a linear optimization problem. I tried like you have in the next image, but I couldn´t get an answer.

1706571743344.png

In this picture, the first line is the file´s name, and the second one is the function´s name.

Can anyone help me, please?

Regards.


0 Likes
Accepted solutions (1)
295 Views
7 Replies
Replies (7)
Message 2 of 8

jason_lightfootVL7B4
Autodesk
Autodesk
Is it in the same folder as the model? Have you set the global preferences to the correct python version? Have you toggled the code as external? Have you put it in a user command? Is your custom code calling a user command? Which activity is calling it? Can you attach your files and model?
0 Likes
Message 3 of 8

diego_rt
Not applicable

I can insert just the Python file. The Flexsim model is too large to send. In addition, I put both files in the same folder, and I selected a Python script in the FlexSim process flow.


If you believe you can help, please text me at my email address, dramatoja@gmail.com, so I can send you the FlexSim file. Here is the Python script:

MinCostFlow.py

I am very grateful for every help you can offer me; it is something important to me.


Thank you.

0 Likes
Message 4 of 8

diego_rt
Not applicable

Here is more information about how I made my connection and why I do not consider this option a mistake.


1706574870805.png

0 Likes
Message 5 of 8

jason_lightfootVL7B4
Autodesk
Autodesk
You can't put flexscript into an external code function like that - you should from your custom code call a user command with parameters to pass to the python function.
0 Likes
Message 6 of 8

diego_rt
Not applicable
I am not sure about how I should do it because I think I did it in the Python file attached before, if I understood well.
0 Likes
Message 7 of 8

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

Here's an example of how to call your Python module from a process flow via a user command and have the returned array added to the token as a label.

minCostFlow.zip

0 Likes
Message 8 of 8

diego_rt
Not applicable
Thank you for your help! It was very useful.