question

Patryk avatar image
0 Likes"
Patryk asked Jason Lightfoot commented

Calculated parameters in Python

I would like to use python code to enumerate parameters in flexsim.

In this way, I send the given parameters in this example, type and weight, to Python and it returns me a calculated value that I can use in the model.

Is there a way to do this ?

1705065670639.png

python-test.fsm:

pyfunction.py

FlexSim 23.2.1
codepythonfunctions
1705065670639.png (117.6 KiB)
python-test.fsm (28.2 KiB)
pyfunction.py (168 B)
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

Your use command should only contain this:

/**external python: */ /**/"pyfunction"/**/
/** \nfunction name:*/ /**/"Flex"/**/

But you should specify the parameter types in the command gui:

1705066831155.png


1705066831155.png (2.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.

Patryk avatar image Patryk commented ·

After he changed use command I have this error
1705141855410.png

0 Likes 0 ·
1705141855410.png (80.0 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Patryk commented ·
Check that the code has been applied in the UserCommand Gui as well as the code gui, and that the python module is in the same directory as the model.
0 Likes 0 ·