3D Grid From Surface

  • Intro
  • 3D Grid from Surface
  • BoxMorph
  • Surface Analysis
  • Color by Slope
  • Conclusion

Information

Primary software used Grasshopper
Course 3D Grid From Surface
Primary subject Parametric Modeling
Secondary subject General
Level Beginner
Last updated November 11, 2024
Keywords

Responsible

Teacher
Faculty

3D Grid From Surface 0/5

3D Grid From Surface link copied

This tutorial is focused on three useful tools in Grasshopper: UV subdivision of surfaces, box morphing and finally coloring based on surface properties

This tutorial is focused on three useful tools in Grasshopper: UV subdivision of surfaces, box morphing and finally coloring based on surface properties. First, we create a lofted surface in Rhino. The surface can be changed by control points along the curves of the loft.

Possible result of this tutorial
Possible result of this tutorial

3D Grid From Surface 1/5

3D Grid from Surface link copied

Create a loft with two curves
Create a loft with two curves

First you set two curves drawn in Rhino and create a loft between them using the loft component.

  • Create two curves in Rhino
Curve
Free-Form
Control Points
  • Create a curve parameter in Grasshopper
Params
Geometry
Curve
  • Set the curves on the curve parameter
Curve parameter
RMB
Set Multiple Curves
  • Loft the curves
Surface
Freeform
Loft

 

Subdivide the surface with UV segments using the isotrim component. The result is a series of smaller surfaces, in other words a panelized surface. These are the cells of your grid.

Divide the surface in smaller surfaces
Divide the surface in smaller surfaces
  • Subdivide the surface
Math
Domain
Divide Domain2
  • Connect two number sliders to the U and V
Params
Input
Number Slider
  • Trim the surface using the UV domain
Surface
Util
Isotrim

 

3D Grid From Surface 2/5

BoxMorph link copied

Once the surface is panelized 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 SurfaceBox command. Connect the original surface and use the Domain from the Divide Domain component. Specify the Height by using a Number Slider. Now you have generated the Target boxes for the geometry.

Create boxes on the isotrim surfaces
Create boxes on the isotrim surfaces
  • Create boxes on the grid using the surface, isotrim and a Height number slider as input Create boxes on the grid using the surface, isotrim and a Height number slider as input
Transform
Morph
Surface Box
  • Define the height with a Number Slider. You may have to use a negative value
Params
Input
Number Slider

Now you can create a geometry in Rhino that you want to morph over the surface. Then set it on a geometry parameter in Grasshopper.

Design a geometry to morph on the surface
Design a geometry to morph on the surface
  • Design the geometry you want to morph over the surface in Rhino
  • Create a geometry parameter
Params
Geometry
Geometry
  • Set the geometry on the parameter
Geometry Parameter
RMB
Set one geometry

Now we create a bounding box around the object. A bounding box is the smallest possible box around an object using the axes of a specific plane. After that, we morph the geometry back to the surface.

Design a geometry to morph on the surface
Design a geometry to morph on the surface
  • Use the bounding box function on the geometry using the content input
Primitive
Surface
Bounding Box
  • Create a surface morph node. Plug the BoundingBox into the Reference Box input on the Boxmorph tool. Finally add the Target boxes from the SurfaceBox command.
Transform
Morph
Box Morph

Note: The box morph is a computationally expensive process, so it may take a while to get the result.

If you want to morph multiple objects to the surface, you can change the bounding box setting by right-clicking and selecting Union Box. You also need to group the objects for the Geometry input.

Use multiple objects to morph
Use multiple objects to morph
  • If using multiple geometries, set bounding box to union box
Bounding Box
RMB
Union Box
  • Group the geometries before the Geometry input
Transform
Util
Group

3D Grid From Surface 3/5

Surface Analysis link copied

The surface subdivision can also be useful in analyzing the surface. For example, by using Evaluate Surface node, 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.

Reparametrize the surface input
Reparametrize the surface input
  • Connect the isotrim surface to an Evaluate Surface node
Surface
Analysis
Evaluate Surface
  • Right-click on the Surface input of the Evaluate Surface component and select Reparametrize
Surface input
RMB
Reparametrize
Find the center of the isotrim surfaces
Find the center of the isotrim surfaces

Using the MD Slider 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.

§  Calculate the center point of the surface with the MD Slider, do not change the values 

Params
Input
MD Slider

§  Connect the MD Slider output to the Point input of the Evaluate Surface node

Internalize the Point input if you wish
Internalize the Point input if you wish

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.

3D Grid From Surface 4/5

Color by Slope link copied

The Evaluate Surface component returns a Point, a Normal and a frame A plane derived from geometry (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 Start from the evaluated surface Point following the Direction of the Normal. The Length doesn’t matter, a Number Slider can be used in this case. The other SDL-line follows the z-Direction, Starting from the same Point, using the same Number Slider for the Length. Make sure they have the same orientation, if not (like in the example here) one of them needs to be inverted by using the negative component.

Create two SDL lines from the evaluate surface output
Create two SDL lines from the evaluate surface output
  •   Create two SDL-lines from the Evaluate Surface Point output
Curve
Primitive
Line SDL
  •   Define a random length with a Number Slider
Params
Input
Number Slider
  •   For the first SDL connect the output Normal from the Evaluate Surface component.
  • If necessary, flip the direction of one of the SDL line direction inputs
Math
Operator
Negative
  •  For the second SDL line use a Z-Unit Vector as input,
Vector
Vector
Unit Z

Now we extract the Endpoints of the lines to easily generate a 2-Point Vector, ensuring the correct direction of both vectors instantly.

Create two vectors from the SDL lines
Create two vectors from the SDL lines
  • Find the endpoints of the SDL lines
Curve
Analysis
End Points
  • Create two vectors from the endpoints per line
 
Vector
Vector
Vector 2Pt

Compute the angle between the two vectors. This equals the slope since calculating the difference between the horizontal vector and the tangent vector on the surface (90 degrees rotated normal) returns the same number.

Calculate the angle between the vectors
Calculate the angle between the vectors
  •  Compute the angle between the vectors
Vector
Vector
Angle
  •   Multiply the output angle with 100 by adding a number slider or a panel with the value 100. Or right-clicking on input ‘B’, hovering over ‘Set Data Item’, enter the number then ‘Commit Changes.’

The final visualization of our model requires an upper limit of the color gradient. We can use the highest angle from the surface geometry as our upper limit. To do so use, a Sort List component and reverse the outcome keys. The use a list item to select the highest value in the list.

Calculate the angle between the vectors
Calculate the angle between the vectors
  •  Find the highest value by using the following, then right-click on keys and select ‘Reverse’.
Sets
List
Sort List
  •  Select the first item using the following. That Bullet points with component location.
Sets
List
List Item
 

For a colored representation of the different slopes we can use a color gradient option. Connect the slope percentages from the Multiplication component into the Parameter t of the Color Gradient. Plug the Divided Surface geometry into a Custom Preview component. Then enter the output of the Color Gradient into the Color input of the Custom Preview.

Display the surface angle using a gradient
Display the surface angle using a gradient
  •  Display the angles of the surface using the t input of a gradient
Params
Input
Gradient
  •  The highest angle output will be your input for the upper-limit input of the Gradient component.
  •  Connect the gradient output to a Custom Preview Shader input
Display
Preview
Custom Preview
  •  Connect the isotrim surfaces to the geometry input of the Custom Preview node
Set the color preset
Set the color preset

There are different pre-sets if you right-click on the colored component. Moving the small dots adjusts the corresponding colors and percentages.

3D Grid From Surface 5/5

Conclusion link copied

In conclusion, you learned how to create a 3D grid using a freeform surface as the basis for the grid, and populate the grid with a defined geometry, and morph it into the surface to create a 3-dimensional geometry. Additionally, you learned how to analyze a surface based on their angles and visualize them using custom gradient presets.

final script
final script
Download final exercise file
application/zip (ZIP, 43 KB)