Assume that you have to create a sphere whose 'x' coordinate always stays right in the middle of the 'x' coordinates of the two other spheres. However, in 'y' and 'z' directions, you should be able to move the sphere without any restrictions.

Constraint objects allow you to set up this kind of relations between objects. To define the relation outlined above:

1. Create three analytic spheres and name them as 'sphere1' 'sphere2' and 'sphere3'

2. Select the sphere1 and activate the Constraint tool. You can access this tool from the menu (Tools/Modifier/Create Constraint). Click Accept.

3. In the select window, drag and drop sphere2 and sphere3 into the created 'constraintX' folder.

4. Select the constraint object, open the properties window and go to the Spec tab. Set Command Language to JavaScript and enter the following program:

var i = 0;
var mid_x = 0.0;

for(i = 0; i < 2; i++)
    child = Self.GETSUBBYORDNUM(i);
    p = child.GetCenter();
    mid_x = mid_x + p.x;

if(i != 0) {
    mid_x = mid_x/i;


The constraint defines all attributes of the associated objects in its own attribute space.