# Grasshopper 3D Grid from Surface

## Introduction

**LEVEL: BEGINNER**

This is a continuation of Grasshopper 2D Grid. This method is based on subdivison (defining U and V values) of a surface which is lofted between two curves. We can change the control points along the curve and manipulate the input surface this way.

## 3D Grid from Surface

First you set two curves drawn in Rhino and create a loft between them using the **UV Surface Divide** example from Grasshopper 2D Grid. You subdivide the surface with the
command. The Isotrim (SubSurface) requires you to divide a UV Domain based on the input Surface. Connect the divided domain and the input surface to the Isotrim (SubSurface) component. The result is a series of smaller surfaces, you've pannelized the surface. These are the cells of your grid.

## BoxMorph

Once the surface is pannellized into a uv-grid, you can use it for many different transformations. One of the transformations we will demonstrate here are the Surface Box and the BoxMorph tool. A SurfaceBox creates 3D cells (with a specified height) from the 2D cells of the divided Surface. The Boxmorph places an object within those 3D cells, automatically adjusting the dimensions of your geometry. It adjusts the BoundingBox of the geometry to match the 3d boxes on the surface, and scales the geometry accordingly.

First, you need to convert the 2D cells to 3D by using the command. Connect the original surface and use the **D**omain from the Divide Domain component. Specificy the **H**eight by using a Number Slider. Now you have generated the **T**arget boxes for the geometry.

Then you can load the geometry you would like to morph over your surface. Use *set one geometry* and make a BoundingBox *per object* with the tool. Then load your **G**eometry into the and plug the BoundingBox into the **R**eference Box input on the Boxmorph tool. Finally add the **T**arget boxes from the SurfaceBox command.

You can use also set multiple geometries, but then you have to set the BoundingBox to *union box* by right clicking on the component and checking *union box*. You also have to ensure that the geometry is grouped before you enter it into the **G**eometry input. To group geometries, use

## Surface Analysis

The surface subdivision can also be useful in analyzing the surface. For example, by using

we can evaluate the surface based on a uv coordinate.

UV coordinates refer to the domain of the surface. For our purposes we will reparametrize the surface, meaning we redistribute the uv domain from 0-1. Right-click on the **S**urface input of the Evaluate Surface component. Select Reparametrize. Now we generate the uv input. This can be done in several ways.

Using the is visually easy to understand as the square lay-out of the slider mimics the uv-point in relation to the surface. The output of the slider is a x,y,z coordinate where the z is always 0.

Another method is creating an x,y,z-point by using and Number Sliders (0-1) for the x and y input. Do not define the z coordinate, as it is not necessary.

The last alternative is to write your coordinates in a panel. Write {0.5,0.5,0.0} to retrieve the centerpoint, for example.

To keep your definition compact you can decide to internalize the uv-coordinate. This means that the data is stored inside the component and is permanent until substituted with another input. Right-click the uv-input and select *internalize data*

## Color by Slope

**LEVEL: INTERMEDIATE**

The Evaluate Surface component returns a **P**oint, a **N**ormal and a **F**rame (plane derived from geometry). We can use this data to analyze the curvature of the surface. In order to visualize this data, we will color the subdivisions according to their slope. This could be useful when you are generating a walkable surface and the slope cannot by higher than 10% (wheelchair accessibility, for example. This can be done in many ways, but to understand the process exactly we calculate the vector of the normal compared to a vertical vector. If we multiply this by 100, we obtain the slope percentage.

To visualize the process we will first draw two SDL-lines . One SDL-line will **S**tart from the evaluated surface **P**oint following the **D**irection of the **N**ormal. The **L** doesn't matter, a Number Slider can be used in this case. The other SDL-line follows the z-**D**irection, **S**tarting from the same **P**oint, using the same Number Slider for the **L**ength. Make sure the have the same orientation, if not (like in the example here) one of them needs to be inverted by using the .

Now we extract the Endpoints *set a number*.

For a colored representation of the different slopes we can use a color gradient option.**t** of the Color Gradient. Plug the Divided **S**urface geometry into a component. Then enter the output of the Color Gradient into the **C**olor input of the Custom Preview.