Amir,
Thanks a lot for your help. I absolutely don’t know the Python language but your example was clear enough to integrate it into my model.
I"m not sure, but i think there is a little mistake in your “filename.py” function : you specify a “context” but never defined it in the AnyBody code (line : def name(context, Basepath, Basename, ext)). Removing this parameter made the function working.
that sounds a bit suspicious to me because for me it is the other way around: when I remove the context variable from the python script the model does not load, and I tested it from the AMS versions 5.2.1 and newer. Anyway, if it is working for you like that leave it.
The context variable is defined by the AnyFunExMonoPy and delivers some information from about the interface like the calling .any script, the filename of the .py script and some other things which you can see in the class example of the reference manual.
Daniel,
If I understand well the code, adding “context” in the python file means that it would also be described in the anybody code when referring the function. In other word, it should be defined in the ArgList, what is not the case :
that is almost true. You can think of the parameter context as predefined and used from the AnyFunEx class which calls and executes the python function, so the values in this context variable can be used in the python script but there is no change to change the these values from AnyScript.
As far as I know the two script names mentioned in the last post and name and abolute path of the AnyScript functions are in this variable. I don’t know what else is in there, but to find out I can recommend to play around with class example, this is a very small example so it should be quite easy to modify it even without knowing much about Python.
May I ask which AMS version you are using currently?