# Grasshopper Extrude-Loft-Contour-Project

## Introduction

From Nurbs to Surface to Polysurface (Brep or Solid)

## Extrude

**LEVEL: BEGINNER**

The example use the

component to use an existing curve in Rhino.

The component is used to make a straight extrusion. Other extrusion options are also available. The direction and distance are controlled by a single vector. The example uses a component to create a vector, which is fed into a component that sets the length (magnitude) of the vector. This is fed into the **D**irection Vector input of the Extrude component.

You might also want to set the extrusion direction by specifying an angle (relative to some vector). You could use one of the components to create a fixed vector that you rotate ( ) around an axis by a set amount of radians or degrees.

## Loft

When you have existing curves that you use to make a loft, you may want to change the position of these curves. You can do this using the

or components. The move component uses vectors to specify the direction and distance.

The first curve is moved in the Z-direction by using a component. The length of this Unit factor is changed by using the **F**actor input with a Number Slider.

The second curve is moved by rotating a Z-vector around the Y-axis using the **A**ngle input and enable 'Degrees', which converts the input from degrees to radians, which are used internally in the component by default.

Note that the component only has one input, **C**urves, for curves that should be lofted. A loft always uses at least two curves, so in this example we need to link both outputs from the Move components to this input, by **holding Shift** for every additional connection.

## Contour

Contours can be derived from any surface using the **S**urface input and (at least) the **D**istance between contours, to be controlled by a Number Slider. By default the direction is set to a Z-direction (0.0,0.0,1.0). You can change this by inserting a X or Y-direction using one of the components.

If you change the input curves, it automatically updates the surface and the location of the contours. By moving the Number Slider you can make changes in the distance between contours. You could for example set this to the minimum or maximum step-height (150mm-180mm) of a stair to generate a walkable surface.

## Project

3D Curves can be projected onto a plane, projected onto a plane along a vector or projected onto a brep. Depending on what you will do after the projection you select which command is most useful. The **G**eometry onto a plane. The input can either be Curves, Surfaces or Breps. By default the plane is the horizontal origin (X,Y) plane. You could use one of the components to define a plane.

To project along a vector you could insert a vector-direction. By default this is set to a negative Z direction. Again, you can insert a for a positive direction, or convert these to a negative direction using the command.

To project onto a brep, using the command, you can only insert **C**urves, no other geometry. Similar to the other Project commands, you can insert also insert a vector direction. Make sure that your the projection is actually hitting the targetted brep, otherwise it will not work.

## Stepped Topography

**LEVEL: INTERMEDIATE**

This tutorial combines the 4 operations above; **extrude**, **loft**, **contour** and **project**. To reduce the complexity and to avoid using data trees we generate the contours by intersection the surface with series of boxes rather than using the contour command.

Set the Curves and Loft a Surface between the curves, as demonstrated previously. Using the command, create a BoundingBox. The BoundingBox finds the minimal box paralel to a coordinate system plane that includes all input geometry, finding the extreme corners of the geometry.
Because this definition is based on a bounding box, it only works if the input curves are paralel to the x-axis or y-axis in plan, aligned with the edges of the bounding box.

Once we have the BoundingBox, we need to divide the height of the Bounding Box based on the distance between contours. We can use a number slider for this. For example, if the distance between contours is 0.5, we need to place a box every 0.5 with a height of 0.5 (0-0.5, 0.5-1, 1-1.5, 1.5-2, 2-2.5, 2.5-3, etc.) untill the total height of the original Bounding Box is reached. If we want to keep the definition parametric, this series of numbers always needs to adjust according to the height of the bounding box. To find the height of the BoundingBox we use the command. This gives the Start and End of a Domain, in this case the lowest and highest z-coordinates of the Bounding Box. When we divide this by our distance between contours (0.5, in the example, or the Number Slider in the definition). We round to an integer (ceiling) by using the command and we add (+1) to include the last contour inside a bounding box as well.

We create a new box using the plane, x-, and y-coordinates from the previous box, but inserting a new domain for the z-coordinates of the new boxes. This domain is constructed by shifting the list (+1 and -1), taking out the first and last number of the list. In order to do so, **W**rap should be set to 'False' and right-click 'Invert' in both cases.Construct the domain by plugging in the (-1) list into 'A' and the (+1) list into 'B'. The result will be a list of domains (0-0.5, 0.5-1, 1-1.5, 1.5-2, 2-2.5, 2.5-3, etc.) which we can insert in the z-coordinates for the boxes. Now you have a box at each specified contour level.

Now we find the intersection between the boxes and the input Surface using the command, inserting the lofted Surface into 'A' and the boxes into 'B'.The result is a series of curves arranged by the correct height which we are going to project onto planes at the corresponding height. In order to do this, we first need to place planes at the correct height. To do this, we can use the same (-1) list component, which has the correct z-values for the planes. We place an horizontal XY-plane and use the command. Connect a z-vector to the **T**ransform input and the XY-plane to the **G**eometry input. Once you load the (-1) list into the z-vector, you will have a plane located at the same height of each contour-line.

To ensure the projection of only one set of curves at the corresponding plane, we need to graft the planes before plugging them into the component. Clean the tree to get rid of 'nulls'. Use component to make planar surfaces.

To conclude the stepped topography we can the surfaces using the Number Slider that determines the distance between contours. Connect a z-vector into the **D**istance input on the extrude component. Plug the contour distances Number Slider into the z-vector.