Previous topic TOC

First script

Next topic

  We start this quick tutorial by creating our first script. Start the program ( "Start->ThreeDimSim->ThreeDimSim 1420" ), and the program will show up with an empty edit window.
First object You define a scene by creating objects and assign them to variables. Example:
var a = Box(25, 20, 30);  // create a box
In this line, a 'Box' object is created and assigned to variable 'a'. When you enter this line in the empty edit window and push the 'start script' button (or menu Script->Start), the script in the (active) edit window is evaluated. As a result, you will find the box rendered in the render window.
! Note

A comment can be entered after a double slash '//'. The comment ends at the end of the line. Also note that a statement ends with a semicolon.

Change current view You can use the distance slider in the toolbar of the render window to move the camera position towards the box. By dragging with the left mouse button in the render window, you can change the angle of view, and by dragging with the right mouse you change the offset of the current view.
Change a property Most classes support one or more properties and methods. For example, we could change the color property of our box by assigning a color value to the color property of the box:
var a = Box(25, 20, 30); // create a box
a.color = RGB(255,0,0);  // assign a red color to the box
A property or method of an object is identified by a reference to the object (in this example 'a'), followed by a dot '.', and then followed by the name of the property or method. (in this example 'color'). When you step thru the program ( use the step button or menu Script->Step) you will see how the render window is reflecting the results of evaluation after each step.
Use a method We use methods to perform some action on an object, like moving the object to another location:
// create a box
var a = Box(25, 20, 30); 
// assign a red color to the box
a.color = RGB(255,0,0);  
// move the box 5 units in x-direction
The method 'move' is performed on our box 'a'. The call to the method results in a translation of the box of 5 units in the x-direction.
File Menu You can save your script using the menu File->Save. Below the menu file you also find some other common commands for opening, saving and printing script documents.
Help Menu The help menu gives you access to the help documentation. When you select a keyword in the script window, like the word 'Box', and then hit the key F1 or select Help->Index,  the help window will pop up with the index tab open on the left side. The selected word is highlighted in the index (if found). Double click on the highlighted word to display the documentation.
Script Menu The script menu keeps all commands for evaluation the script. You already used the Start and Step command. A script evaluation can be paused (Script->Pause), halted (Script->Stop) and paused when the interpreter hits a breakpoint. You can set breakpoints by using the Script->Toggle breakpoint command, or by clicking in the left margin of the script window. A red dot will appear indicating the breakpoint is set. Although a breakpoint can be set on any line, the evaluation of the script will pause only at breakpoints set on lines containing statements.