Grasshopper Surface Manipulation

From TOI-Pedia


The Result of this tutorial

Using Grasshopper as a parametric design tool gives us the ability to study different design solutions. In this tutorial we will create a Grasshopper model that gives us the ability to study the openings in a curved roof. By changing the a slider the size of the openings either decreases or increases.

The Design

Before we start building the grasshopper model we should determine some of its basic properties. We will start with a single curved surface in Rhino, which represents our roof. Our roof needs several openings to let light through. The openings are created by raising the middle of a line straight up creating a arc from one side to the other through this raised point. The aspects we want to study are how many openings we should have and how large they should be.

So our variables/parameters are:

  • number of openings
  • height at the middle of the openings

Building the grasshopper model

Step 1 - Preparing the Rhino scene

Drawing a curved line

First of all we need to define our roof in Rhino. We do this by creating a curve and extruding it to get our surface.

Curve » Free-Form » Interpolate Points

Our curve

It's probably easiest to draw the curve in “Right”-view.

Extrude curve

Now we will extrude this surface in a straight line.

Surface » Extrude Curve » Straight

Extrude curve in Front-view

It's probably easiest to extrude the curve in “Front”-view.

Our roof surface

Our surface should look something like this. This will be our starting point for the Grasshopper model.

Step 2 - Starting the Grasshopper model

Create a Surface component

First we have to define the surface we created in Rhino. Therefor we create a Surface component.

Params » Geometry » Surface

For users using Rhino 5 instead of 4 use:

Params » Geometry » Brep

Connect the Surface component to the Rhino surface

Now we have the Surface component we can connect our Rhino surface.

RMB on the surface » select “Set one Surface” (or Brep) and click on the surface we created in Rhino

BRep Components

We need to divide the surface. There are several ways to divide a surface, but in this case dividing the edges is good solution. Thus, we need to identify the edges. We can do that with a BRep Components.

Surface » Analysis » BRep Components

Connecting theBRep Components

Now we connect the output of the Surface component with the input of the BRep Components.

List Item

The surface has four edges and we only need to divide two of them. So we somehow need to identify those two edges. If we hover with our mouse over the E of the BRep Components it shows us that the output is a list of four curves. With the function List Item, we can specify specific items in a list. We need to identify two edges, so we make two List Items. Note that computers start to count with zero, so the edges are 0, 1, 2 and 3. Sets » List » List Item

Setting the integer

For the two List Items we need to set which item from the list we want. We need to specify which two items of the list correspond with the two edges we need.

RMB on the i in the List Item » select “Set Integer” and set it to the right value

We might need to double check if we have the right edge. We need the two curved edges. We can check if we specified the correct edges by selecting the List Item and looking in the Rhino viewport to see which edges are selected (colored green).

Divide Curve

Now we have the two edges identified we can divide them.

Curve » Division » Divide Curve

Number Slider

As we want to set the number of divisions for the curve, we create a Number Slider to control this.

Params » Input » Number Slider

We double-click on the number slider to change it's properties and set the rounding to integers.

Connecting the Divide Curve and the Number Slider

When we connect them, we will see the division on the edges of the surface in our Rhino view.

Creating a line

We need curves from the division points on one side to the division points on the other side.

Curve » Primitive » Line

Connecting the line to the two lists

Now we connect the two lists of division points.

Crossing lines

The only problem is we don't get the result we wanted. The lines are linked in a crossing pattern.

Reverse a list

We need to reverse one of the lists of division points.

Sets » List » Reverse List

Inserting the Reverse List

We need curves from the division points on one side to the division points on the other side.

Our correct division lines

Now the curves are correct.

Step 3 - Creating the second set of curves

Divide Curve

We want to get the middle of our newly created division curves, so we use another Divide Curve.

Curve » Division » Divide Curve

Set the integer to 2

We only need to divide the curves in two parts to get a point in the middle of the curve.

RMB on the N in the Divide Curve » select “Set Integer” and set it to 2

Add another List Item

The Divide Curve creates three points on the curves, so we need another List Item to identify the correct point.

Sets » List » List Item

Set the integer to 1

We need the second point, so we set the integer to 1 (computers usually start counting with 0, 1, 2, etc.).

RMB on the i in the List Item » select “Set Integer” and set it to 1

Decompose the 3d-point

Now we have identified the second point, we want to be able to move it in the Z-direction to create the openings in the roof. An easy way to get to the Z-value is to decompose the 3d-point into X, Y and Z values.

Vector » Point » Decompose

Decompose the 3d-point

We just simply connect the List Item to the Decompose.

Create an Addition component

As we wanted to manipulate the Z-value we are going to do two things. First we create an Addition component.

Math » Operators » Addition

Add a Number Slider

Secondly, we create a Number Slider to control the size of our openings.

Params » Special » Number Slider

Re-compose the 3d-point

After adding a value to the Z-value we can re-compose our 3d-point. We can do this with the component Point XYZ.

Vector » Point » Point XYZ

Re-compose the 3d-point

We just pass on the X and Y values from the Decompose component. The Z value will be the result of the Addition comonent.

Creating an arc

Now that we have the raised midpoint of the curves, we can create arcs going from one side through the raised midpoint to the other side.

Curve » Primitive » Arc 3Pt

Re-compose the 3d-point

The points on the edges were already define to create the first curves, so we can use them again. We just need to make sure we connect them in the right order. We have now created the second set of curves.

Flatten the input

If we connected the points correctly we see arcs being created in a crisscrossed pattern, instead of just one arc being created for every row of points. This has to do with the way data is gathered in Grasshopper. We will explain this in a later stage. For now all we need to know is that we need to flatten the data.

RMB on all the Inputs of the Arc 3Pt » click on “Flatten”

This will flatten our data, making it able to combine the different point data.

Step 4 - Creating the surfaces

Connecting the Cull Index

We now have two sets of curves, and we want to create a loft from the first arc to the second straight line. We could do this in several ways, but in this tutorial we will clean the list of curves by removing the curves we don't need. This means we will delete the first straight curve and the last arc.

Sets » Sequence » Cull Index

With the Cull Index we can delete specific items from a list or set of objects.

Cull Index

We need to specify which items from the list we want to delete. Removing the first item of a list isn't very complicated, because we know the first item always has the index number 0.

RMB on the I of the Cull Index » select “Set Integer” and set it to 0

List Length

Removing the last item from a list is a bit more complicated, because we need to know the length of the list. The length of the list is the number of items in the list.

Sets » List » List Length

Adding an expression

The fact that computers start to count with zero, means that the number of values is always 1 higher than the highest list item. For example, if you have 4 points, the points are indexed as follows: 0, 1, 2 and 3. Therefore we need to subtract 1 from the list length to be able to select the highest list item.

RMB on the I of the Cull Index » select “Expression” and enter x-1

List structure

We now have the right items in the two lists, but if we try to loft the outputs of the two lists it won't give us the desired result. It just makes one loft going through all the arcs and one loft going through all the straight lines. This happens because the two lists are structured in a way that Grasshopper combines all the items in one list to make the loft instead of combining one value of the first list with one value of the second list.

If we look at the data in the list by using a panel, we can clearly see different structures in both lists. Pay special attention to the darker yellow lines. We can see different numbers of zeros between the accolades. To be able to combine two lists, we need to get this structure identical in both lists.

Flatten tree

First of all, what we can do is simplify the list structure. We could do this in more than one way, but in this case we will use the "Flatten Tree" component to do this. This component will get rid of any unnecessary layers in the list hierarchy.

Sets » Tree » Flatten Tree

The result is an identical structure in both lists, but lofting the outputs of these two lists still doesn't give us the desired result. It combines the two lists, but not by lofting them one by one, but all of them at once.

Graft tree

We have to somehow tell Grasshopper to divide the lists in separate items, so it will loft them one by one.

Sets » Tree » Graft Tree

Adding the final component: Loft

We can now use these lists as input for the loft component.

Surface » Freeform » Loft

Personal tools