Lesson 1: Basic concepts

The AnyBody system contains an editor designed for authoring AnyScript files. So the first thing to do is to get AnyBody up and running. Double-click the AnyBody icon, and you should be greeted by the AnyBody Assistant and behind that an empty workspace.

As you can see, the Main Frame window contains a smaller frame at the bottom. This frame provides much of your interaction with the system once you have a model running. Notice now in particular the empty rectangular lower portion of the frame. It is the Output Window. The system talks to you through this window. Notice that this window as well as many other text views in AnyBody can contain active links like in a HTML browser. These links can help you navigate faster around in the system.

As computer software goes, AnyBody is much like any other Computer-Aided Engineering tool. You can create data from scratch, you can read in previously defined data, and you can exchange data between models. Once you have your data in place, you can perform various actions on it. Let us begin by creating a new AnyScript model. The menu clicks File -> New Main will bring up a new window in which you can construct your model using the AnyScript language.

The new windows is basically a text editor. This main pane of the Editor window will contain the actual AnyScript text. The system has already created the skeleton of a model for you from a built-in template.

The narrow pane attached to the left side of the Main Frame is a tree view pane, where you find hierarchical representations of the model defined in the text window. If you are familiar with modern feature-based CAD systems, this idea will be very familar to you. Almost the same tree views are available on the Editor windows containing the AnyScript code, but they are closed by default. These additional tree views give you the possibility to browse large models in several views at a time. The following tree views are available to you:

  • The Model Tree View shows all objects in the model. It is current
  • The Operation Tree (only on the Main Frame) shows a subset of the model objects but in the same structural ordering. The objects in this subset are so-called operations that are the things you can do to the model. An operation can be selected in the Operation Tree and thereafter controlled by the Run, Step, Reset, etc. buttons below (or on the Main Frame toolbar or the Operations menu). More about operations will follow later.
  • The File Tree shows all the files in a model. So far we will only be working with one file, the so-called Main file.

On the Editor windows, you will additionally find some tree views that do not show the objects of the model, but things available to you while modeling.

  • The Class Tree shows all the classes in the AnyScript language and it can assist you in inserting the code to create objects.
  • The Global and Function Trees show the globally available elements, hereunder functions, in the lanugauge.

So far the Model, the Operation and the File Trees are empty, because the model is not yet loaded into the system. In the upper left corner of the editor you see the little icon . This means "Script to Model". When you click this icon, the system processes whatever text you have in the editor window and tries to form a valid AnyBody model. The tree view gets generated and updated this way. A similar button is found in the Main Frame toolbar and the key F7 is a convennient shortcut for this function.

The script to model operation also saves your model files. The first time you save a new file, AnyBody requires you to give your model a name, so clicking the  icon the first time produces a "Save As" dialog.

Let's have a look at what the system has generated for you. If we forget about most of the text and comments, the overall structure of the model looks like this:

Main = {
  AnyFolder MyModel = {
  }; // MyModel
  AnyBodyStudy MyStudy = {
  };
}; // Main

What you see is a hierarchy of braces - just like in a C, C++, or Java computer program. The outermost pair of braces is named "Main". Everything else in the model goes between these braces.

Right now, there are two other sections inside the Main braces: The "AnyFolder MyModel" and the "AnyBodyStudy MyStudy". These are the two basic elements of most AnyBody models. The term "AnyFolder" is very general. In fact, any pair of braces in AnyScript is a folder. You can think of a folder as a directory on your hard disk. A directory can contain other directories and files. It's exactly the same with folders. They can contain other folders and elements of the model. The "AnyFolder MyModel" is the folder containing the entire model you are going to build. The name "MyModel" can be changed by you to anything you like. In fact, let's change it to ArmModel (in the forthcoming AnyScript text we'll highlight each change by red. Just type the new name into the file, and don't forget to also change other occurrences of MyModel to ArmModel in the file.

Notice the prefix "Any". All reserved words in AnyScript begin with "Any". This way you can distinguish the elements that belong to the system from what the user defines. Another way of recognizing reserved words is by virtue of their color in the editor. Class names are recognized by the editor as soon as you type them and colored blue.

It must be emphasized that AnyScript is case sensitive.

There is more to an AnyScript file than the model. Once you have a model, you can perform various operations on it. These operations are often collected in "studies", and the "AnyBodyStudy MyStudy" is indeed such a study. You can think of a study as the definition of a task or set of tasks to perform. The study also contains methods to perform the tasks. The Study of Studies tutorial contains much more information about these subjects. For now, let's just rename "MyStudy" to "ArmModelStudy".

Let's look a little closer at the contents of what is now the ArmModel folder:

// The actual body model goes in this folder
AnyFolder ArmModel = {
  // Global Reference Frame
  AnyFixedRefFrame GlobalRef = {
    // Todo: Add points for grounding
    // of the model here
  }; // Global reference frame
  // Todo. Add the model elements such as
  // segments, joints, and muscles here.
}; // ArmModel

Most of what you see above is just comments. It is always useful to add lots of comments to your models. Notice that one-line comments are started with //. Multiple-line comments are enclosed in /* */ just like you may know it from C++ or the Java language. Notice also that lines are terminated by semicolon ';'. Even the lines with closing braces must be terminated by a semicolon. If you do no terminate with a semicolon, then the statement continues on the next line. You can comment and uncomment a block of lines in one click by means of the buttons at the top of the Editor window.

The only actual model element in the ArmModel is the declaration of the "AnyFixedRefFrame GlobalRef". All models need a reference frame - a coordinate system - to work in, so the system has created one for you.

An AnyFixedRefFrame is a predefined data type you can use when you need it. What you have here is the definition of an object of that type. The object gets the name "GlobalRef", and we can subsequently refer to it anywhere in the ArmModel by that name.

You will notice that there is a "to do" comment inside the braces of this reference frame suggesting that you add points for grounding the model. Don't do it just yet. We will return to this task later.

But here's an important notice: Everything you define in this tutorial from now on is part of the ArmModel folder and should go between the its pair of braces. If you define something outside these braces that should have been inside, then the necessary references between the elements of the model will not work.

What you have here is actually a valid AnyScript model, although it is empty and cannot do much. If you have typed everything correctly, then you should be able to press the  icon and get the messages

Loading Main : "C:\...\NewModel1.any"
Scanning...
Parsing...
Constructing model tree...
Linking identifiers...
Evaluating constants...
Configuring model...
Evaluating model...
Loaded successfully.
Elapsed Time : 0.063000

 

in the Output Window. But what happens if you mistype something? If your typo leads to a syntactical error, then it will be found by the AnyBody system when it parses the file, and instead of the "AnyScript loaded successfully", you will get an impolite message that something is wrong. A common mistake is to forget a semicolon somewhere. Try removing the last semicolon in the AnyScript file, and load again. You get a message saying something like:

ERROR(SCR.PRS11) : C:\...\NewModel1.any(27) : 'EOF' unexpected
Model loading skipped

 

We now assume that you have removed eventual errors and have loaded the model successfully.

If you are up to it, let's continue onward to Lesson 2: Segments.

This is a typical error message. First there is a message ID, then a file location and finally the body of the message. The former two are written in blue ink and underlined to show the underlying active links. The file location is the line where the bug was found by the system. If you double-click this link, the cursor in the Editor Window jumps to the location of the error. Notice that this is where the system found the error, but the error can sometimes be caused by something you mistyped earlier in the file so that you actually have to change something elsewhere in your model. If you are in doubt of what the error message means, try clicking the error number ERROR(SCR.PRS11). This will give you a little pop-up window with a more complete explanation:

AnyBody Technology A/S · Niels Jernes Vej 10 · DK-9220 Aalborg Ø · Denmark · Tel. +45 9635 4286 · Fax. +45 9635 4599
Copyright (c) AnyBody Technology A/S · 2006 · All rights reserved · Email webmaster@anybodytech.com