I run some parametric studies with AnyPyTools and would like to know if there is an option to comment out a #include-command or undo a #define-command in my AnyBody Model using AnyPyTools ?
I included an exoskeleton to the human model by #include and want to run the one part of the parametric study with the exoskeleton and the other part without.
I was hoping there is a more convenient way to do that other than having two different main files.
I suggest you wrap your #include statements inside an #if - #else - #endif statement. So, firstly you make a define statement for the exoskeleton condition (with or without), and in your model, have all the changes wrapped inside the if-else statements.
Then, you can you use AnyPyTools to generate macros while setting define through AnyPyTools.
One issue that you will face in this way is when you run the main file directly in AnyBody, you will use the define statement, but when you run it through AnyPyTools, the same define will be defined twice and create an error. You can avoid that by setting a default define inside an #ifndef - #endif statement in your main file. Here is an example:
Yes, there is an example showing how to do that in the link I posted above. So, following the example I wrote above, i.e., #define EXO "WExo", you can write the command through AnyPyTools like this:
An other good tip is to structure your models in a smart way. I.e.include everything outside the studies, and then make references to the body parts you need in the different studies. A study only runs simulations on the parts of the model it has references to.
Here is a small example with pseudo code:
Main = {
AnyFolder HumanModel = {};
AnyFolder ExoSkeleton1 = {};
AnyFolder ExoSkeleton2 = {};
// This study will only run simulations with exo1
AnyParamStudy ParamStudy1= {
AnyFolder& BodyModel = .HumanModel.BodyModel;
AnyFolder& Exo1= .ExoSkeleton1;
};
// This study will only run simulations with exo2
AnyParamStudy ParamStudy2= {
AnyFolder& BodyModel = .HumanModel.BodyModel;
AnyFolder& Exo1= .ExoSkeleton2;
};
};