# Tutorial 1 - Rotating Tower

## Introduction

The Result of this tutorial

One of the main uses of Grasshopper is to build simple parametric models. In this tutorial we start by exploring these possibilities by dealing with some of the basic operations. To show this we will make a simple parametric tower. To work with complex objects, a design process usually starts from a very simple first level and then other layers are added; complex forms are comprised of different hierarchies, each associated with its own logic and details. These levels are also interconnected and their members affect each other and in that sense this method called ‘Associative’. So let us start by describing the towers basic properties.

## The Design

Before we start building the grasshopper model we should determine some of its basic properties. The design we want to achieve is a tall tower with a bottom and top profile. The precise shape of the profiles is not fixed and alternatives need to be explored. Furthermore we are aiming at a minimal total floor area of 35.000 m2.

File:Grasshopper tut1 sketch.jpg
Sketch of the proposed design

Other properties include:

• radius of the bottom shape
• radius of the top shape
• floorheight

# Building the grasshopper model

## Step 1 - Starting the grasshopper model

Create point in origin

Now that we have defined the input we can determine what components we need to build the model. As mentioned before, the process of making a complex model usually starts from a very simple level. In this particular design we will start by making a line which will act as the core of the building. Any line is constructed by connecting two points. Therefore we start by creating the two points; one at the origin and one moved in the Z-direction controlled by the height property.

Vector » Point » Point XYZ

We leave the input to its default 0,0,0 thereby creating a point in the origin of the model.

Create second and a number slider

Next we want to create the second point.

Again we start by creating a point, but now we are going to control the Z value by the use of a slider.

Vector » Point » Point XYZ

And now the slider

Params » Input » Number Slider

Edit the slider properties

We want to change the setting of the slider so that it conforms to our use. For each slider one can set the type of numbers, lower and upper limits and its default value.

RMB on the slider » Edit

Set the lower limit value to 3.000 (the minimum height is 3 meter)

Set the upper limit value to 300.000 (the maximum height)

Rename slider

Now it is a good habit to give your slider an appropriate name

RMB on the slider » first item in the popupmenu controls the name. Set it to “buildingHeight”

Connect the slider to the point

We can connect the number slider to the Z input of the point.

Drag the output of the slider to the Z input of the second point.

Create the line

Using the two points we can create the line connecting them. First we create the line, then we connection the two points to input A and B of the line.

Curve » Primitive » Line

Connect the points to the line

Drag the output of the first point to the A input of the Line

Drag the output of the second point to the B input of the Line

The result of these first steps are visible in the perspective window in Rhino. You should see a line in the Z direction. Changing the “buildingHeights” sliders value should change the height of the line.

## Step 2 - Create the bottom and top shapes

Create the two polygons

For the bottom and the top shapes we choose to use a polygon as base. We will use the two points created earlier as the basepoints of the shapes. For the polygon we need to specify the number of sides and the outer radius. Both these values are driven by the design and the designer and are controlled by sliders.

Create the first and second polygon

Curve » Primitive » Polygon 2x

The polygon has 4 inputs:

• P – The baseplane or point for the polygon
• R – The outer radius of the polygon
• S – The number of sides of the polygon
• Rf – The radius of the optional rounded corners

Create the slider for the radius

Params » Special » Number Slider

We want to change the setting of the slider so that it conforms to our use. There is a minimum and a maximum radius.

RMB on the slider > edit

Set the lower limit value to 5.000 (the minimum radius is 5 meter)

Set the upper limit value to 25.000 (the maximum radius is 25 meter)

Rename the slider

RMB on the slider > first item in the popupmenu controls the name. Set it to “outerRadius”

Edit the slider properties

Next create the second slider for the number of sides. This slider requires for an important setting as the number of sides can only be a whole number, a so called “integer”

Create the slider for the number of sides

Params » Special » Number Slider

We want to change the setting of the slider so that it conforms to our use. There is a minimum and a maximum number of sides and, most important, a type of values available.

RMB on the slider > edit

Set the rounding to Integer

Set the lower limit value to 3 (less that 3 sides create a line and has no area)

Set the upper limit value to 10 (the maximum number of sides)

Connect the sliders to the polygons

Rename the slider

RMB on the slider > first item in the popupmenu controls the name. Set it to “numberOfSides”

Now connect the output of the sliders to the polygons. It is important to notice that one slider can control multiple objects, making it easier to control complex models.

Drag the output of the “outerRadius”t to the R input of both the Polygons

Drag the output of the “numberOfSides” to the S input of both the Polygons

Connect the points to the polygons

Both polygons are now created in the origin of the model. As mentioned before we will use the 2 points created before as input.

Drag the output of the first point to the P input of the first polygon

Drag the output of the second point to the P input of the second polygon

Result of the second step.

Lets review what we have constructed until now. We should have 2 polygons; one at the bottom of the line and one at the top of the line. Check whether changing the numberOfSides and the outerRadius changes the two polygons accordingly.

## Step 3 – Adding Rotation

Result of the second step.

The effect of the rotated tower is controlled bij the rotation of the top shape. To enable this we need a rotate option and a slider to control this rotation.

Create rotate

First we create the rotate option and connect the top shape output to the rotate Transform » Euclidean » Rotate

Drag the output P of the top shape to the input G of the rotate

Create Slider

Now we need to define the angle of rotation. For this particular design we want to be able to rotate the top between 0 and 180 degrees. So we create a slider with floating point numbers as option and connect this to the rotate.

Params » Input » Number Slider

Setup Slider

We want to change the setting of the slider so that it conforms to our use. There is a minimum and a maximum number degrees to rotate.

RMB on the slider > edit

Set the lower limit value to 0.0000 (0 equals no rotation)

Set the upper limit value to 180.0000 (the maximum rotation)

Connect Slider

Connect the output of the slider to the input A of the rotate.

Hide Polygon

Now let review what we have done in the viewport of rhino and check if the grasshopper definition works. The first thing you might notice is that there are actually two top polygon shapes (if you don’t see two you need to increase the rotation). The reason why this happens is that the rotate option actually takes the geometry, copies and rotates it according the specified angle. Because grasshopper definitions work as a downward stream of data this is the only way to do this. We can solve this quite easily by hiding the original polygon.

RMB on the second polygon > toggle preview

The second polygon will be hidden and the rotated copy will remain visible. Also notice the Polygon Icon turning into a darker grey color.

The second issue that we have to deal with is the rotation. Given the minimum and maximum values that we have set for the slider we can expect the top polygon to rotate 180 degrees. If we check this in the model we can see that the object actually rotates a lot more than 180 degrees. Further inspection shows that the input A of the rotate expects a rotation in Radians instead of Degrees (hover with your cursor above the A shows this popup).

Make function block

So we need to convert degrees to radians. For these kind of calculations we can use a function block. Function blocks a especially useful for creating more complex mathematical calculations.

Math » Script » Evaluate

We choose F1 because we have only one value to use in our calculation.

Connect function

We start by connecting the output of our degree slider to the input x of the function.

Connect output of the slider to the input X of the function

Set function

Next we need to set the function: what needs to happen with the input. The function block comes with a separate editor which has numerous mathematical functions to choose from. Besides the ones visible in the toolbars there is also a “Expression function list” which shows the complete list of available functions. In this list we can find the “Rad(x)” function which converts the value X (in degrees) to radians. Close this list.

Type Rad(x) in the Expression input field.

Click “OK”

Our function in place

Now we need to connect the output of the function to the input A of the rotate.

Connect the output of the function to the input A of the rotate.

Check using a panel

We can check whether this works by reviewing the output of the function block and comparing this to the specified number of degrees in the slider. Checking you output is a useful habit and makes searching for errors a lot easier. The common practice is to use a Panel. A panel is basically a text-like field that displays the input.

Params » Input » Panel

Connect the output of the function to the input of the panel

In our example the degree slider is set to 45 degrees. If we convert this to radians (multiply the degrees times pi/180) we expect a value of 0.785 so it works!

Loft the two curves

Now that we have both bottom and top profile set we can connect them to make the outer surface of the tower. For this we use the loft component. The loft connects the curves in the order they are connected and forms a surface that runs through these curves. Therefore they can be considers sections through the surface. It is important to notice that we want to connect multiple sources (curves) to one input (the input of the loft. To accomplish these we can hold the “shift” key to connect more than one object to an input.

Surface » Freeform » loft

Connect the bottom polygon output to the S input of the loft

Connect the top polygon output to the S input of the loft WHILE HOLDING THE SHIFT KEY

Resulting Lofted surface. It looks like a tower!

Now we can review the overall shape of the tower in the Rhino perspective view. Try changing some of the slider input to see the impact on the model.

## Step 4 – Creating the floors

Slider connected to the curve Division

In the beginning of this design some requirement were set. One of those requirements is the minimal needed floor area in the building. To calculate this we first need to model these floors. Again, before we start the modelling, we need to define what kind of input and output we need. The output is composed of two parts; first we want to see the floor slabs in our model and second we want the total amount of square meters. The input is relatively simple; we need to specify the number of floors and we need to specify the thickness of the slabs. There are two methods to specify the number of floor; by defining a number or by defining the floor height for each floor. In our design we choose the second option because we are looking for an usable design.

Furthermore we are reusing a component that we have build in the beginning: the core-line. This will act as the main driver for the division of the floors. Grasshopper has the option to position points along a curve. We are using these points as the input for the positioning of our floors. The input will be a slider defining the height of the floors. To make life easier we first will temporarily hide the outer surface of the tower created earlier.

RMB on the Loft > Toggle Preview

Params » Special » Number Slider

Again we want to change the setting of the slider so that it conforms to our use. There is a minimum and a maximum height.

RMB on the slider > edit

Set the lower limit value to 2.8000 (minimum 2.8 meters)

Set the upper limit value to 6.0000 (maximum 6 meters)

Rename to floorHeight

Points along the line controlled by the floorHeight

Now we can create the curve division and connect these. Please take notice of the other division types.

Curve » Division » Divide Distance

Connect the output of floorHeight to the input D of the division

Connect the output of the line to the input C of the division

We can check the output in our Rhino Model view. You will see a series of points along the line.

Plane positioned on each point

Because the shape of the tower is not known at the beginning of the process (we can rotate the top shape and change the number of sides of the tower) we need to create the floors based on the outer shape of the tower. To create the needed outer curve an intersection at each floor with the outer surface needs to be made. The intersection is made between a (virtual) plane and the outer surface. The plane uses the points on curve as center point.

Vector » Plane » XY Plane

Connect the output P of the Divide Distance to the Input O of the XY Plane.

Notice that for each point a plane is created. This is actually one of the more powerfull features of Grasshopper: Because the Divide Distance creates multiple points, the XY Plane treats each point as a centerpoint for a new plane, thereby making it easy to define one action for multiple objects.

Outer Curve for the floor. Notice that the intersection appears even when the outer surface is hidden

Using the plane the intersection with the outer surface (also called a “BRep”) can be made.

Intersect » Mathematical » Brep_Plane

Connect the output P of the XY Plane to the P input of the Intersect

Connect the output L of the previously created loft to the B input of the Intersect

Floors created

The curves define the outer boundary of the floors. Using a plane command the floor surface can be created. Surface » Freeform » Planar Srf

Connect the output C of the intersect to the input E of the Planar Srf

Calculate the Area of each floor

With the surface for each floor created the area can be calculated using the Area component. A panel is created to review the result

Surface » Analysis » Brep Area

Connect the output S of the Planar Srf to the input B of the Brep Area

Params » Input » Panel

Connect the output A of the Brep Area to the input of the panel

In the panel window the output of the Area component is visible. Notice that it treats each floor as an individual element and therefore calculates the area for each floor.

Difference between a normal and a flattened list

To calculate the total floor area all the individual floor areas need to be added. This can be accomplished with the use of the Mass Addition. This will be placed between the Brep Area and the Panel. For the Mass Addition the list of individual floor areas needs to be treated as one. This is done using the flatten command.

Sets » Tree » Flatten Tree

Connect the output A of the Brep Area to the Input D of the Flatten Tree

Create a panel and connect to the output of the Flatten Tree

The difference is in the way Grasshopper treats the values in a list. In the first (not flattened) list each value is a separate object (also called a separate branch), in the flattened list it is one object with multiple values.

Total Floor Area calculated using the Mass Addition

Math » Operators » Mass Addition

Connect the output D of the Flatten Tree to the input I of the Mass Addition

Connect the output R (the result) to the input of one of the panels

Delete the other Panel

The value in the panel is the total area of all the floors combined. In this example the total area is appr. 29100 square meters. There are several options to influence this value:

• Change the buildingHeight > a higher building can contain more floors, hence more floor area
• Change the outerRadius > larger floors
• Change the floorHeight > more or less floors
• Change the rotation > although the influence is minimal
• Change the number of Sides > also minimal influence

So you could image the number of different alternatives you could create all with around 35000 square meters.

Floors Have thickness

The last step is creating the thickness of the floors. To accomplish this the surface is extruded to the specified thickness. A slider will be used as input for the extrude. The extrude need a direction. In this case the Z-direction will be used.

Params » Special » Number Slider

Again we want to change the setting of the slider so that it conforms to our use. There is a minimum and a maximum thickness.

RMB on the slider > edit

Set the lower limit value to 0.1000 (minimum 0.1 meters)

Set the upper limit value to 0.5000 (maximum 0.5 meters)

Rename to floorThickness

Create the direction Z and connect the slider to the direction. The slider will act as an multiplier on the direction, which has a default value of 1.

Vector » Constants » Unit Z

version 0.7.XXX or later:

Vector » Vector » Unit Z

Connect the output of the floorThickness to the input F of unit Z

Next create the extrude component

Surface » Freeform » Extrude

Connect the output S of the planarSrf to the input B of the extrude

Connect the output V of the UnitZ to the input D of the extrude

The inputs of this model
The complete grasshopper definition

This is the end of this tutorial. The resulting Grasshopper Definition allows the designer to generate alternatives using the various inputs defined in this tutorial.