question

MPeyman avatar image
0 Likes"
MPeyman asked MPeyman commented

read python file in flexsim

Dear All, I wanted to try to add the global table from my python file but after many tries I couldn't and I get this error: ( also I created an empty python file as mentioned in other questions called __init__.py but it didn't work)

exception: Code Binding Error: could not bind to function

Node: /Tools/UserCommands/getData/code

Binding string: /**external python: */ /**/"InputGenerator_nodes2"/**/

/** \nfunction name:*/ /**/"read_location_data"/**/

Windows Error Code : 1400


Here I attached the files:

InputGenerator_nodes2.py

try1.fsm


Function: read_location_data()

getData("Instances","p1.2.a.txt").as(Array).as(Table).cloneTo(Table("GlobalTable1"))


FlexSim 23.0.8
flexsim python
try1.fsm (25.2 KiB)
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

Kavika F avatar image
0 Likes"
Kavika F answered MPeyman commented

Hey @MPeyman, the error you're getting suggests to me that your names python file name doesn't match the "external python" name. If you fix the name of your file to match the one in the data, then it should work.

1705511168108.png

1705511177427.png

Another note: your User Command "getData" takes in 2 parameters, but your python function doesn't take any. You may want to add those parameters to your python function if you'd like to pass them in. Otherwise you'll get this error:

read_location_data() takes 0 positional arguments but 2 were given


1705511168108.png (6.9 KiB)
1705511177427.png (2.1 KiB)
· 7
5 |100000

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