Move a Cube
Introduction
Expected Time: 15 min
In this tutorial you will learn how to place an object in Grasshopper and move it. Generally speaking, this can be done in two ways: using an object from Rhino or create an object in Grasshopper. First you will learn how to use objects from Rhino. If you would like to know more about the different types of data Grasshopper can use, take a look at the
Modules wiki page.
Cubes
If you want to move a cube, we will first need to make an original cube. This cube can be generated in Grasshopper, or just be drawn in Rhino. In this example, we will draw a cube in Rhino.
- Draw a cube in Rhino
Move
To move an object in Grasshopper we first need to select an object to move in Grasshopper. If you use existing geometry from Rhino the geometry is already defined. That means that you can define that geometry as a Parameter. It might be necessary to cut a part of the design if the part which you want to move is connected to another object. You can connect it again once the final design is established.
- Add a Geometry Parameter to the canvas
Although we just selected a geometry parameter type, there are several other parameters available. If you would like to move a point for example, it is recommended to use the point parameter. When you are outputting data, you should use the data parameter.
Next, we need to connect our box from Rhino to the geometry parameter in Grasshopper. Right click on the geometry parameter and click on Select one Object. The Rhino viewport will now open. By selecting the box, you will see it is highlighted green or red. This indicates that the geometry is connected to Grasshopper. After connecting the geometry to the Grasshopper parameter, you can hide the Rhino box.
- Connect the box to the Grasshopper parameter
- Hide the Rhino box
Now we will move the box. Connect a move component to the geometry parameter. First add the move component to the canvas, and then draw a wire between the parameter output and the Geometry input.
- Move the Geometry
Vector
Next to a geometry input, the move component also has a motion input. If we hold our mouse on the motion input, we can see that it requires a translation vector. Currently, the motion is set to {0, 0, 10} which leads to a movement of 10 units in the z-direction.
A Vector describes a direction and distance. Vectors are widely used in Grasshopper and form often the basis for complex transformations. The vector can be defined in three ways.
- The easiest vector to create is a Unit-X, Unit-Y or Unit-Z. By adding a number slider, you can define the length of the vector in the specified direction.
- A XYZ vector. This is a vector in the X, Y or Z direction. The distance of the vector is based on the X, Y and Z values you input with a number slider or a value.
- A point can also work as a transformation vector. This point can be created or an existing point can be used. If the point has the coordinates of X=2, Y=4 and Z=6 and it is used as a move vector the object will move 2 units in X direction, 4 units in Y direction and 6 units in Z direction.
- If you have two points then you can use these points to define a vector
Combine Vector and Move
Now we are able to combine the vector and move node. In this example, we used a Unit-X vector. By right-clicking on the original object and selecting preview, we only see the translated object. You just created your first Grasshopper script!
By changing the value of the Number Slider, you can see that the box moves in the Rhino viewport.