Hi,
I am trying to run a model through python. The thing is i need to run the same model multiple times with different inputs.
My input is a text file. I use AnyInputFile to load the input data and then use AnyOutputFile to output the muscle activity for all muscles. Now, the input and output filename changes and i will have to run same model for multiple versions of the input and output.
Therefore, i am using python to run and I am running into problems. I am inputting the input filename using setvalue command. I am pasting my sample code underneath.
input_list = ['D:\Yokhesh\data\input.txt','D:\Yokhesh\data\input1.txt',]
macrolist = [
mc.Load("move_test.Main.any"),
mc.SetValue("Main.Model.datafun.FileName", input_list),
mc.OperationRun("Study.InverseDynamics"),
mc.Dump("Main.Study.Output.Model.BodyModel.Right.ShoulderArm.Mus.biceps_brachii_caput_breve.Fout"),
]
app = AnyPyProcess()
parameter_study_macro = AnyMacro(macrolist, number_of_macros= len(input_list) )
output = app.start_macro(parameter_study_macro)
Firstly, the python output says that the operation has failed and the output log is as follows:
Macro command > load "move_test.Main.any"
Loading Main : "D:\move_test.Main.any"
Scanning...
Parsing...
Constructing model tree...
Linking identifiers...
Evaluating constants...
Configuring model...
Evaluating model...
Loaded successfully.
Elapsed Time : 12.601000
Macro command > classoperation Main.Model.datafun.FileName "Set Value" --value="D:\Yokhesh\data\input.txt"
ERROR(SCR.EXP2) : Edit std::string : 'D' : Illegal type conversion to 'AnyFileVar'
||============================Edit Value==============================
||
|| FileName = "..........\Yokhesh\data\input.txt"
|| FileName =||====================================================================
||==========================Message Dialog============================
|| Error : Set value is not allowed for given model running state.
|| Press : < OK (Any Key) > : OK
||====================================================================
Macro command > operation Study.InverseDynamics
Macro command > run
Secondly, the operation takes very long to complete. If i run the model in anybody, it takes 120 seconds to complete. But, if i run it in python, it takes close to 1300 seconds to give me an output.
Could you please take a look at my error and let me know if i can use python to run the code multiple times while just changing my input and output file for each iteration ? Also, could i improve the speed of execution ?
Thanks,
Yokhesh