Import data form AnyOutputFile

Hi all,
I run a batch Model in which I generate an .txt Document via AnyOutputFile in the first Case of the Batch in which I save three AnyFloats as seen below.

AnyOutputFile Save_lr = {
FileName = "Save_lr.txt";
SepSign = " ";
Header.TitleSectionOnOff = Off;
Header.ConstSectionOnOff = On;
Header.ConstSectionSaveOptionsOnOff = Off;
Header.VarSectionOnOff = Off;
Header.ColumnNamesOnOff = Off;
SuppressTimeColumnOnOff = On;
Main.KneeModel.Save_lr.Header.ShortenNamesOnOff = On;
Main.KneeModel.Save_lr.Format = 0;

   AnyFloat aMCL_lr = Main.KneeModel.Forces.Ligaments.aMCL_Force.lr;
   AnyFloat mMCL_lr = Main.KneeModel.Forces.Ligaments.mMCL_Force.lr;
   AnyFloat pMCL_lr = Main.KneeModel.Forces.Ligaments.pMCL_Force.lr;

};

In the following Cases I want to use said values. For that i want to import them via AnyImportFile but I am not managing it.
Can anyone tell me how I can use the values I output again in my code?
Btw I am quite new to Anybody so a easy explenation would be wonderfull.
Thanks in advance.

Hi Scheuer

Welcome to the AnyScript Forum!

To read in the data from a text file, you would use the class AnyInputFile. Once you read in the data, you can use AnyFunInterpol to generate an interpolation function for your data. Then you can use your data as a function of time in your simulation.

Since this is quite often the case, you can directly use the class AnyFunInterpol as it also has the option to read in data from an input file. Please see the reference manual and the demo example for AnyFunInterpol. I would suggest that you keep your output file simple as the file reader in AnyBody automatically parses data and that most often means it will assume data starts at a line that begins with numbers. Ideally the first column in your input file should be time. This will normally be the case if you use a file generated by AnyOutputFile. You should be able to read it without problems.

Your code could look something like this:

    AnyFunInterpol TestFile = {
      Type = Bspline;
      FileName = "Save_lr.txt";
    };

You can also search for AnyFunInterpol and AnyInputFile on the forum to find more posts dealing with these classes.

I hope that helps.

Best regards,
Dave

Hi Dave,
Thank you for your answer. But my Problem lies before that. Everytime I try to Import my .txt File and read the Values in the File, it is not possible. As far as I can deduct, the Problem lies in the format of the Files. AnyOutputFile generates an output that AnyInputFile can not read. Is there a way to format the AnyOutputFile so that I can use the Values I save in the .txt File with AnyInputFile?

Hi

Can you please share the error message that you get? That will help me identify the problem.

Best regards,
Dave