Lesson 1: Basic Concepts#
Note
To follow this tutorial it is recommended to first to watch the introductory video found in this link “Tutorial Overview”.
To create an AnyScript model from scratch, go to “File menu -> New from template…” this will bring up a new window in which you choose “Basic Main” and provide a “Target Name” (e.g., NewModel) and click OK. This is similar to this step from the previous tutorial.
The new file that opens up in the text editor contains a basic skeleton for your model, based on a built-in template.
What are Classes?#
Let’s have a look at what the system has generated for you. If you ignore most of the text and comments (green lines beginning with //
),
the overall structure of the model looks like this:
tl;dr
When you load the model, the name assigned to a pair of braces, and all the contents between the braces will show up as folders and sub-folders in the Model Tree.
The code creates two objects - MyModel
& MyStudy
- which perform very
specific functions, which depend on the pre-preprogrammed object types (AnyFolder
& AnyBodyStudy
)
used to create these objects. These inbuilt object types are also known as CLASSES.
Main = {
AnyFolder MyModel = {
};
AnyBodyStudy MyStudy = {
};
};
What you see is a hierarchy of braces - the outermost pair of braces is named Main = {
.
Everything else in the model goes between these braces.
“MyModel” (of class type AnyFolder
) is simply an
organizational folder for containing the entire model you are going to
build. Let us change the folder name “MyModel” to “ArmModel”.
The object named “MyStudy” (of class type AnyBodyStudy
) is a collection of
simulation tasks that you want to perform with your model. The Study of Studies tutorial
contains much more information on simulation studies.
Attention
All changes you need to do in your model will be highlighted in red in future tutorials.
👉 Now reename MyStudy
to ArmModelStudy
, and replace all occurences of MyModel
with ArmModel
.
What does this file contain so far?#
// The actual body model goes in this folder
AnyFolder ArmModel = {
// Global Reference Frame
AnyFixedRefFrame GlobalRef = {
// Todo: Add points for grounding of the model here
};
// Todo: Add the model elements such as
// segments, joints, and muscles here.
};
Within ArmModel = {}
is an object named GlobalRef
, created with the AnyFixedRefFrame
class. This object is the global reference frame for your model.
You will notice “Todo:” comments inside the braces, to which we will return later.
Note
The model objects that you create henceforth must be placed within the “ArmModel” folder and should go between its pair of braces.
Loading an AnyBody model#
You should be ready to load the model now. If cannot recollect how this is done, refer to this section from a previous tutorial.
You may get message similar to the one below, in the Output Window.
Loading Main : "C:\..\NewModel.main.any"
Scanning...
Parsing...
Constructing model tree...
Linking identifiers...
Evaluating constants...
Configuring model...
Evaluating model...
Loaded successfully.
Elapsed Time : 0.030000
Basic troubleshooting#
If you mistype something, you will get an error message. A common mistake is to forget a semicolon somewhere. Try removing a semicolon and re-load the model, which may give you an error message like this:
Attention
The error messages may look different depending on which semi-colon you removed. Missing semicolons can be tricky, so keep that in mind.
ERROR(SCR.PRS11) : C:\\...\\NewModel.main.any(26) : 'EOF' unexpected Model loading skipped
The message contains clickable links for both error code and the location of the error in your file. Upon clicking the file link, the text cursor jumps to the exact problematic line in the file. Remember that an error can sometimes be caused by something you mistyped earlier in the file.
Clicking the error code, e.g: ERROR(SCR.PRS11)
opens a pop-up window with a complete explanation:
We now assume that you have removed the errors and have loaded the model successfully. If you are up to it, let’s continue onward to Lesson 2: Segments