Grasshopper Curve Frames-Arrays

From TOI-Pedia


Expected Time: 75 min

In this tutorial, you will learn using the remap tool in Grasshoppper and controlling a set of geometries with the Graph Mapper. In the first section a recap will be given about planes, as described in Tutorial 8 Ramp Easy. Next, you will learn some components relating to arrays. Finally the concept of mapping will be explained.

Horizontal Frames

In this first example, horizontal frames will be demonstrated. There is a difference between dividing a curve and connecting those points with a line versus creating perpendicular lines from the curves. This can be useful in creating stairs along a a curve, for example.

The script for an offsetted line with connections in between.

In the right picture, you can see a script that is used to connect lines between division points of two curves. First, the curve is set from Rhino to Grasshopper with Params » Geometry » Curve. After that, the curve is offsetted using Curve » Util » Offset with a Number Slider for Distance. Division of both curves with the same number using Curve » Division » Divide and connecting one Number Slider to both divides the components with the same Number.

The Rhino model following from the script.

Using a Curve » Primitive » Line component you can connect the two points. This is explained into more detail here: Grasshopper Points from Curve. Notice that the connecting lines are not perpendicular. This is because the equal divisions of the curve are not perpendicularly placed across each other.

Connection lines using horizontal frames.

If you want perpendicular lines to the curve, you use the Curve » Division » Horizontal Frames command instead. Instead of returning a point, the Horizontal Frames returns a plane, oriented with a x-direction tangent to the curve and a y-direction perpendicular to the plane. Use a Number Slider or set a number to control the Number of Horizontal Frames. (Note: These are called Frames because they are planes derived from geometry)

The resulting Rhino model.

To draw a line along the y-axis of the planes, use Vector » Plane » Deconstruct Plane to extract the directions of the vector. Now use Curve » Primitive » Line SDL with the Starting point at the origin of the Frame and the y-direction of the deconstructed vector into the Direction. The Length of the line can vary, using a Number Slider.

If the direction of the offset and the SDL do not match, you can invert one or the other by using the Math » Operators » Negative tool. To complete the example, use an Curve » Util » Offset. The Distance should equal the length of the SDL line, by connecting the same Number Slider. If you want to retrieve the intersection points at the offset curve, use Intersect » Physical » Curve-Curve.

You can now delete or save this script for future use. We will continue with another example.

Perpendicular Frames

Connection lines between curves using perpendicular frames.

In addition to Horizontal Frames, Grasshopper also has a tool to distribute Perpendicular Frames with the Curve » Division » Perp Frames component.

The resulting Rhino model.

If you follow the same steps as above, you'll see that in this case the y-direction of the plane follows the z-direction of Rhino's world coordinate system and the x-direction is perpendicular to the curve.

You can now delete or save this script for future use. We will continue with another example.

Curve Array

Script for a curve array.

The difference between this method and the previous ones is that here we define a geometry to distribute along a curve rather than defining a point or plane to draw geometry upon or move geometry to. In this example we start with curve-geometry to be converted into a solid, but you can start with any type of geometry (point, curve, surface, brep) or even multiple geometries.

Resulting Rhino model.

First, in Rhino, define your geometry to be arrayed along the curve. In this case, we have drawn a cross-like curve and set one curve. To convert this to a solid, we use Surface » Freeform » Extrude and Surface » Util » Cap Holes. For the extrusion, define the direction, in this case the z-direction by using Vector » Vector » Unit Z. If we connect the capped Brep to the Geometry input of the Transformations » Array » Curve Array command, it will distribute the geometry along the curve by a defined Number. This can be adjust by using a Number Slider or set a number.

You can now delete or save this script for future use. We will continue with the next tutorial.

Distance based Scaling using Remapping

Example of the goal for this tutorial

In this chapter, you will learn how to use the remap tool. This can be useful for example, if you want to change a parameter based on a relation to another parameter. Imagine the following situation: based on the curve we drew in the previous exercise we will extrude geometry along the curve. However, the extrusion should be larger when it is further from the start point. Furthermore, the extrusion should be at least 1 and have a maximum of 10.

Example of the goal for this tutorial

Add two curve parameters to the canvas. The first parameter should hold the base curve. The second parameter should hold a closed curve, for example a star, at the start of the base curve.

  • Add two curve parameter to the canvas Params » Geometry » Curve
  • Set the base curve and the geometry to array on the parameter RMB on curve parameter » Set one Curve

An array of geometries along the base curve

Next, create a curve array of geometries along the base curve.

  • Connect the curve parameters to a Curve Array as illustrated Transform » Array » Curve Array
  • Define the amount of geometries with the count input Params » Input » Number Slider

Find the location of the geometries on the curve

Now we need to find the location of the geometries, based on the curve length. First, use the Area node to find the Centroid of the geometries. After that, use the Curve Closest Point node to find the location. As you can see, the Curve Closest Point has three outputs: Point, Parameter and Distance. In our case, the Parameter output describes the location on the curve.

  • Find the centroid of the Arrayed Geometries Surface » Analysis » Area
  • Use the curve closest point to find the Parameter on the curve Curve » Analysis » Curve Closest Point

In the next step, we need to find the height of the geometries. Take a look at the following example, and try to figure out if you understand what happens:

Visual explanation of remap component

Add a remap component to the canvas
  • Add a Remap Numbers component to the canvas Maths » Domain » Remap Numbers

Connect the Parameter output to the remap node
  • Connect the Parameters of the Curve Closest Point to the Value input of the Remap Numbers node.
  • Add a bounds component between the parameters output and the Remap Numbers Source input Maths » Domain » Bounds

Set the minimum and maximum of the height

Create a domain between 1 and 10 for the Target input of the Remap Numbers component.

  • Connect a Construct Domain to the Target Maths » Domain » Construct Domain
  • Add a Number Slider to the start and end of the Construct Domain Params » Input » Number Slider

Check if the values are correct

Now check if the values from the remap component gives values between your created domain with a panel.

  • Connect a panel to the remap output.

Connect a Z-Unit vector to the values

Change the values to a Z-Vector by connecting it to a Z-Unit vector.

  • Add a Z-Unit vector to the canvas and connect it to the remap output Vector » Vector » Unit Z

Extrude the geometries

Now extrude the geometries along the base curve using the Z-Unit vector as direction.

  • Extrude the geometries Surface » Freeform » Extrude

Cap the holes of the extruded geometries
  • Cap the holes of the extrusions Surface » Util » Cap Holes

The final model

Your model is now finished!

The final Grasshopper script

Distance based Scaling using Graphmapper

To control, for example, the height of the geometry according to a numeric graph, you can use the Graphmapper command. This component functions can be used a input for the Value input of the Remapping tool, to get for example, a sin-like shape. The Graphmapper will create a range of numbers according to a defined graph. For this tutorial we will use the script from the previous chapter.

In the following image, the Graph mapper will be explained. Take a look to find out if you understand how it works.

Explanation of the Graph Mapper

Remove unnecessary nodes

First, we have to remove and disconnect a few components from the previous script.

  • Remove the bounds component
  • Disconnect the Parameter output (Curve Closest Point) to the Value input (Remap Numbers)

Add a range node

Add a range component to the canvas. Connect the Number Slider with the amount of points to the Steps input. You can leave the Domain input as it is.

  • Add a Range node to the canvas Sets » Sequence » Range
  • Connect the previously created Number Slider to the Steps input

Add a Graph Mapper
  • Connect a Graph Mapper to the range output Params » Input » Graph Mapper

Specify the type of Graph
  • Select the type of Graph you want RMB on Graph Mapper » Graph Types » Parabola

Change the shape of the graph

By clicking on the white points of the Graph, you can alter the shape of the Graph.

Connect the Graph Mapper to the Remap Numbers node
  • Connect the Graph Mapper to the Value Input of the Extrude node

Remove unused nodes
  • Remove the unused Area node
  • Remove the unused Curve Closest Point node

Final Rhino model!

You now have an arrayed geometry along a curve. The height of the extrusions is based on a Graph Mapper!

Personal tools