Changing the TrailFileName with AnyPy Tools

Hello all,

I am doing an analysis of the motion of the upper limb extremities. I have recorded some Motion Capture data and I have the c3d files. Now I would like to analyse it with a model that I did adapting the full gait model. It runs perfectly.

Now I want to automatize the analysis with the AnyPy tools and basically what I want to do is:
-Load the file
-Change the TrailFileName
-Run the analysis
-Save the data

I managed to do everything expect the key point: Changing the TrailFileName.

Could you please tell me the command to do so.

Thank you very much for your help.


Hi @Enric

I don’t think you can change the TrialFileName after the model has loaded. That helps specify which c3d file is read in the load process. There are two solutions to what you want to do:

You can either (1) use some path statements to set the trial name, or you can (2) structure you model with multiple main files so it isn’t necessary.


Try to add the following to your TrialSpecificData.any file

#path TRIAL_FILE_NAME "some_default_trial_name"

TrialFileName = TRIAL_FILE_NAME; 

Now the model will use the trial name stored in the path statement TRIAL_FILE_NAME.

That statement can be controlled by AnyPyTools when you make the macro:

Macro = [
   Load('FullBody.main.any',  paths={"TRIAL_FILE_NAME": "Some_other_trial_name"})


Alternatively, you can structure your code similar to the “Multi trial MoCap example”.

This is a nice way of doing things since it makes much easier to switch between trials when you are just debugging and setting up your models. I use this approach on most of my models. AnyPyTools also handles this very well. The start_macro() method has a search_subdirs argument which will allow you to search for all the main files, and hence to batch processing this way.

>>> app.start_macro(macro, folderlist, search_subdirs = "*.main.any")

See this link:


Thanks for your quick reply.

I would like to go for the first solution since the second solution would mean the creation of too many main files. I have 10 subjects, 9 different movements and 8 repetitions for each. Therefore, this means that I would have to create 720 main files right?

Then, trying to implement the first solutions I have the following problems:

  • First, I have to include the c3d files in the Setup folder to be able to call it without putting the whole path.
  • Second, I have to add .c3d --> “THE_NAME_FILE.c3d” and I do not know if this will imply a problem later on the code since the script is made to work without.
  • Third, I get this error:

Loading Main : “C:\Users\Enric\Desktop\Hard-Disk contents III\Plug-in-gait_Simple Mark\Sub1Sim.any”
Constructing model tree…
ERROR(OBJ.FILE1) : C:/U…s/E…c/D…p/H…I/S…g/A…o/T…s/A…p/ModelSetup.any(93) : ModelSetup.C3DFileData.FileName : Problem with file : C:\Users\Enric\Desktop\Hard-Disk contents III\Plug-in-gait_Simple Mark\Input\C:\Users\Enric\Desktop\Hard-Disk contents III\Plug-in-gait_Simple Mark\Setup\S1P2_3mm.c3d.c3d : Failed to open the specified c3d file
Model loading skipped

Which basically the path it has been add to the other path where I do not know where it is declared to commented out or modified and it has the double “.c3d.c3d” in the name file which I do not know if it will be a problem later.

I appreciate that you take some time to solve this issue.

Thank you very much for your help,


Yes. But it doesn’t have to be that hard. Note that the main files are all identical. In most cases the TrialSpecificData.any file is also identical, since it picks up the trial name from the parent folder. So creating a new trial is as easy as coping a folder and renaming it accordingly.

The main advantage with this approach is debugging and working with the models manually in AnyBody. I have used it for models with more that 120 subjects and 4000 trials. Of course, in that case I would automate the creation of the files :slight_smile:

I think that approach is fine. I don’t have too much experience with a big setup using that approach but it is definitely possible and I would like to help make it happen.

The TrialFileName is for the name of the trial without extension (e.g. without .c3d). If you want to specifiy where the c3d files are stored there is a MOCAP_C3D_DATA_PATH path statement ) that you can set. (edit: see this link)

#path MOCAP_C3D_DATA_PATH "path/to/c3dfiles"

If all you C3D files are in the same folder, you can place this statement in the LabSpecificData.any file.

If you remove the .c3d extension the error should go away.



Thank you for your help. Finally I went for the first option. I did not realise that in this format also the TrailSpecificData.any was identical. Knowing that creating folders is just as easy as copying the files. Additionally with help of some file renamers, I have used advanced Renamer, it is easy to rename them properly. Thus, it is a bit of work but doable.

Thank you for your help. I think I manage to make it work.


This topic was automatically closed 125 days after the last reply. New replies are no longer allowed.