AnyOutputFile Help

Hi,

I am looking for a hand with outputting data to a .csv document. I know this is possible through the use of AnyOutputFile and inputting the class template. However following this I am confused as to the remainder of the formatting to be done (Am currently an AnyBody novice). If someone could spare a second to help a system novice out that would be swell, I am currently trying to simply output the left and right hip forces before moving on to muscle comparison data outputting.

Cheers,
Nick

Hi Nick,

I think you are on the right track. You can use the AnyOutputFile and use the file extension .csv. If you switch off the header sections and change the separators like this

      SepSign = ",";
      LineSepSign = "";
      Header = {
        TitleSectionOnOff = Off;
        ConstSectionOnOff = Off;
        VarSectionOnOff = Off;
        ColumnNamesOnOff = Off;
        //LinePrefix = "// ";
      };

you will get a csv formatted file.

You have probably looked at the class example of the AnyOutputFile which is linked in the reference manual. This is probably the easiest way to play around with the output format.

Best regards
Daniel

Hey Daniel,

Cheers for the reply, apologies for the novice questions, but when using the anyoutputfile class template; how exactly do you designate the data pathway that you want to output? and for .csv format, is the number format section left as is? again apologies for the ridiculously mundane questions.

Cheers,
Nick

Also, currently I am reciving the following error:

ERROR(SCR.PRS13) : C:/P…s/A…y/A…0/AMMR/A…n/M…s/M…l/MoCap_LowerBody.main.any(80) : ‘AnyVector’ : Reserved identifier used for object name

What mundane/basic error am i commiting? my code is as follows:

AnyOutputFile dataoutput= {
  FileName = "dataoutput.csv";
  NumberFormat = {
    Digits = 15;
    Width = 22;
    Style = ScientificNumber;
  };
  SepSign = " ";
  LineSepSign = "";
  Header = {
    TitleSectionOnOff = Off;
    ConstSectionOnOff = Off;
    VarSectionOnOff = Off;
    ColumnNamesOnOff = Off;
    LinePrefix = "";
  };
  AnyVector JointReactionForce =Main.Studies.InverseDynamicStudy.Output.BodyModel.SelectedOutput.Right.Leg.JointReactionForce.Hip_*
  AnyVector JointReactionForce =Main.Studies.InverseDynamicStudy.Output.BodyModel.SelectedOutput.Left.Leg.JointReactionForce.Hip_* 
};

Hi Nick,

You are mixing up a few things in your code, but your code is pretty close to a proper solution.
Basically you cannot use

     AnyVector JointReactionForce =Main.Studies.InverseDynamicStudy.Output.BodyModel.SelectedOutput.Right.Leg.JointReactionForce.Hip_*
  AnyVector JointReactionForce =Main.Studies.InverseDynamicStudy.Output.BodyModel.SelectedOutput.Left.Leg.JointReactionForce.Hip_* 

because here you are trying to assign an AnyFloat to an AnyVector which causes an error due to type conversion. You could fix this using ‘{ }’ around the AnyFloat. Then, you are using a wildcards ‘*’ in your object name, which is not allowed. Last, you try to define the JointReactionForce twice inside the object dataoutput, which is also not allowed. Well, a minor thing is that you forgot the semicolon at the end of the line.
So one way to fix it is to list all the values you would like to have in your output file:


    AnyOutputFile dataoutput= {
      FileName = "dataoutput.csv";
      NumberFormat = {
        Digits = 15;
        Width = 22;
        Style = ScientificNumber;
      };
      SepSign = ",";
      LineSepSign = "";
      Header = {
        TitleSectionOnOff = Off;
        ConstSectionOnOff = Off;
        VarSectionOnOff = Off;
        ColumnNamesOnOff = On;
        LinePrefix = "";
      };
      AnyVector JointReactionForce = {
          Main.Studies.HumanModel.BodyModel.SelectedOutput.Right.Leg.JointReactionForce.Hip_MediolateralForce,
          Main.Studies.HumanModel.BodyModel.SelectedOutput.Right.Leg.JointReactionForce.Hip_ProximoDistalForce,
          ...
      };
    };

where the … are just there because I was too lazy to type in all hip joint reaction forces. You can probably handle that.
Oh, one other thing: You should not use the variables from the output in the AnyOutputFile.

The easier solution would be use a search string in the AnyOutputFile. Therefore, you remove the AnyVector and set the Search variable of the AnyOutputFile object to


Search = "Main.Studies.HumanModel.BodyModel.SelectedOutput.*.Leg.JointReactionForce.Hip_*";

This is probably the solution you were aiming for when you started using the wildcards in yout expressions.

If you haven’t done already, I would recommend to read the AnyBody tutorials, especially the “Getting started: AnyScript Programming” which tells about the basics of AnyScript.

Best regards
Daniel

Daniel you are a legend, unfortunately I won’t be able to test this for another week but I’m sure it will work.

On a side note: I’ve found several differing references on whether the anyoutputfile should be in the main script or under inversedynamics sub ‘folder’ (or whichever study your outputs apply to). Where would you recommend?

Cheers,
Nick

That depends on how you use it in the model. Basically it doesn’t matter as long as it is in a folder that is contained or at least referenced in the Study.

[ul]
[li]If you think it is an essential part of the model you are creating, e.g. because you have several studies using this model with the AnyOutoutFile, put it into the model. But you should be aware that the csv file is overwritten each time you run a study containing the AnyOutputFile[/li][li]If it is only for a specific study and you don’t want to have it when you use the model in another study, put it into the study.[/li][/ul]
Cheers,
Daniel

Cheers mate, thanks for the help and advice.

Nick

Hi Daniel,

After re-persuing the tutorials and several other models, for some reason i still have issues with this simple task of obtaining an csv output file. I am simply running the ‘MoCapModel’ (lower body) to suit my c3d data no matter the location of my AnyOutputFile i get a plethora of errors that do not exist when i comment it out (model executes inverse dynamics perfectly). Do you have any advice in terms of this?

Cheers,
Nick

Hi Nick,

difficult to say what goes wrong without seeing what you have done. Could you post the error messages and the model or at least the changes in your model?

Best regards,
Daniel

Hi Daniel,

All my error messages pertain to the use and placement of brackets leading me to believe i am having issues with the placement of the code section you posted previously as without this included code my model runs perfectly.

I currently cannot post my code or error messages. I hope this gives some sort insight, if not i will upload the model or code as soon as i can, most likely the weekend.

Cheers,
Nick

Hi Nick,

for me your description of error messages gives me the insight that I cannot really help without seeing more of your code and error messages, sorry. Maybe you can send it at some point.

Best regards,
Daniel