Modeling hierarchy and structure

Hi all,

One of the strengths of the repository is that you can use pieces from one model and easily use it in another. This is the case for both the application and body branches. However, one recurring issue that I have found is that many pieces of code in one branch (probably only the application, but I am not sure of some of the custom code out there), directly references some directory in the other branch. This is fine, and I think the intended use, but can make things difficult if integrating different parts of unique models.

This issue can readily be seen when one includes a body model in a Main application. It usually looks something like:
#include “…\Body\AAUHuman\BodyModels\FullBodyModel\BodyModel.any”

The problem becomes this type of structure (and #include) occurs in many places (i.e. getting a scaling law, using the toolbox for conditional contact, etc.) If one wanted to simply move the model into another directory that is not on the same level, you would need to change the “…” in many places (not to mention if you wanted to use a different ‘custom’ body model structure).

This may be already implemented in V4, but I am not sure. My solution was to create a list of reference strings at the beginning of my main model that are directory references, e.g.:
AnyString BodyModel_Folder = “…\Body\DavesTempFolder\BodyModelDirectory”;

Then in the code, anytime I want to include something in that main body model folder, I could type something like:
#include BodyModelFolder_1 + “FullBodyModel\BodyModel_Mus3E.any”;

This would make it so if I did change directory structures, I would only need to change it in one place (in the AnyString). Obviously I tried this and I don’t think the #include statements were intended to interpret variables defined in the AnyScript (because I think the #include is called before any variables get defined).

Is there a workaround for doing something like this…maybe with #define in v4?? I think this would be a nice feature to have in the ‘professional’ repository to allow even more flexibility with the models. Just a thought…

Best,
David

Hi David

You are absolutely right, this would be a nice feature to have implemented, and it is actually possible in Ver.4. :wink:

Please see the small example :

/** Small demo that illustrates #path preprocessor statements
*/
Main = {
#path MyPath “/TestDir”
#include “<MyPath>/test.any”
AnyFolder F = {
#include “<MyPath>/test.any”
};
}; // Main

We will make use of this in one of the forthcoming releases of the repository.

Best regards
Søren