# Grasshopper: Learning Resources

Because Grasshopper runs within Rhino, a basic knowledge of Rhino commands and procedures is essential for the beginning Grasshopper student.

BOOKS:

AAD_ALGORITHMS-AIDED DESIGN, by Arturo Tedeschi. The book covers Grasshopper in a thorough, detailed fashion, with many example definitions to try.

VIDEO TUTORIALS:

David Rutten, the creator of Grasshopper, has several tutorials online. Here are two introductory ones:

https://vimeopro.com/rhino/grasshopper-gettingstarted-by-david-rutten/video/79844992

https://vimeopro.com/rhino/grasshopper-gettingstarted-by-david-rutten/video/79844298

Mode Lab has an excellent series of Grasshopper tutorials: http://tinyurl.com/z6nubjw

Digital Toolbox has a collection of tutorials organized by experience level. Although some of the tutorials are designed around older releases of Grasshopper and thus may require some interpretation in order to implement, they give a good feel for how the software works. Here are the links:

http://digitaltoolbox.info/grasshopper-basic/

http://digitaltoolbox.info/grasshopper-intermediate/

# Step-by-Step: Brick Wall on Curved Path 1. In Rhino: Use the BOX command to construct a “brick” with one corner at 0,0,0. Use the CURVE command to construct an arbitrary curved path. [The Grasshopper definition will stack the “brick” along the curved path.]
2. Insert the Brep and Crv parameters. Right-click on each in turn to “Set one Brep” and “Set one Curve.” 3. Insert the Deconstruct Box component. Connect the Brep output to the Deconstruct Box input. [Deconstruct Box allows you to measure the X, Y, and Z dimensions of a Box.] 4. Insert two instances of the Deconstruct Domain component. Connect the X output of Deconstruct Box to the input on the first Deconstruct Domain component; connect the Z output of Deconstruct Box to the input on the second Deconstruct Domain component. [Deconstruct Domain extracts the beginning and end points of a domain, in this case the beginning and end points of the X and Z dimensions of the “brick”.] 5. Insert two instances of the Subtraction component. Connect the S output of the first Deconstruct Domain component to the B input of the first Subtraction component; connect the E output of the first Deconstruct Domain component to the A input of the first Subtraction component. Repeat this process with the second Deconstruct Domain and Subtraction components. [The results of the two Subtraction components represent the length and height of the “brick,” respectively.]

6. Insert the Length component and connect it to the Curve component. [This simply measures the length of the Rhino curved path. We will reference it later.] 7. Insert a Number Slider. Edit its values as follows: Name: Height. Rounding: Integer Numbers. Numeric domain: Minimum: 1. Maximum: 10. 8. On another area on the Canvas, insert the following components: Multiplication, Series, Vector XYZ, and Move. [We will use these components as part of a process to copy the curved path in the vertical direction.] 9. Connect the components: Connect the R output of Multiplication to the N input of Series; connect the S output of Series to the Z input of Vector XYZ; connect the V output of Vector XYZ to the T input of Move. 10. Right-click on the S output label of Series and select Graft. [The Graft option changes the data structure of the parameter. Instead of creating a single list of items, it effectively associates each item in a list with a unique source. In our definition, choosing the Graft option will cause Grasshopper to “remember” that the instructions apply to individual bricks.] 11. Insert a Panel component. Edit its value to equal 2, and connect it to the B input of Multiplication. 12. Copy-paste this entire group of components (i. e., Panel, Multiplication, Series, Vector XYZ, and Move) and set the new components below the original ones. 13. Connect the components: Refer back to the earlier components we placed. Connect the R output of the second Subtraction component to the A input of each of the Multiplication components (two connections). 14. Connect the components: Again referring back to the earlier components we placed, connect the output of the Number Slider to the C input of each of the Series components (two connections). 15. Insert a Division component. Connect the L output of the Length component (i. e., the Length component which measures the length of the Rhino curve) to the A input of Division. Connect the R output of the first Subtraction component to the B input of Division. 16. On another area on the Canvas, insert the following components: Panel (with a value of 2); Division; Multiplication; Series; Shift List; and Cull Nth. [We will use these components as part of a process to copy the “brick” along the curved path. The Shift List and Cull Nth components are critical to shifting the bricks by half their length on every alternating copy of the curved path.] 17. Connect the components: Panel output to the B input on the Division and Multiplication components; R output of Division to N input on Series; R output of Multiplication to C input of Series; S output of Series to L input of Shift List; L output of Shift List to L input of Cull Nth. 18. Refer back to components placed earlier. Connect the R output of Division (i. e., the Division component connected to the Length component) to the A input of the Multiplication component. Connect the R output of Subtraction (i. e., the first Subtraction component, connected to the Deconstruct Domain component) to the A input of the Division component. 19. Insert a Series component. Connect the R output of Subtraction (i. e., the Subtraction component referred to in the preceding step) to the N input of Series. Connect the R output of Division (i. e., the same Division component referred to in the preceding step) to the C input of Series. 20. On another area of the Canvas, insert the following components: Boolean Toggle, Evaluate Length, and Orient Direction. [The Orient Direction component is responsible for making multiple copies of the original “brick” at the correctly placed and oriented locations along the curved paths.] 21. Connect the components: Output of Boolean Toggle to the N input of Evaluate Length; P output of Evaluate Length to the pB input of Orient Direction; T output of Evaluate Length to the dB input of Orient Direction. 22. Copy-paste this entire group of components (i. e., Boolean Toggle, Evaluate Length, and Orient Direction) and set the new components below the original ones. 23. Insert the following components: Panel (value of 1) and Vector XYZ. Connect the output of Panel to the X input of Vector XYZ, and connect the V output of Vector XYZ to the dA input on each of the Orient Direction components. 24. Refer back to components placed earlier. Connect the Brep (Rhino “brick”) output to the G input on each of the Orient Direction components. 25. Connect the S output of Series (i. e., the Series component placed in step 19) to the L input of the first Evaluate Length component). 26. Connect the G output of Move (i. e., the Move component placed in step 8) to the C input of the first Evaluate Length component).

27. Connect the L output of Cull Nth (i. e., the Cull Nth component placed in step 16) to the L input of the second Evaluate Length component).

28. Connect the G output of Move (i. e., the Move component placed in step 12) to the C input of the second Evaluate Length component). 29. Connect the R output of Subtraction (i. e., the Subtraction component placed in step 5) to the S input of Series (i. e., the Series component placed in step 12). 30. Finally, connect the output on the Crv parameter (i. e., the Rhino “path”) to the G input of each of the Move parameters (i. e., the Move parameters from steps 8 and 12). 31. The definition is complete.

# Step-by-Step: Lofted Surface Along Curve in Grasshopper 1. In Rhino, use the Curve command to draw an arbitrary curve in 3D space.
2. Start Grasshopper.
3. Insert the Curve parameter. 4. Right-click on the Curve parameter and choose Set one curve. Click on the curve you drew in Rhino.
5. Right-click on the Curve parameter and choose Reparameterize. This forces Grasshopper to measure values along the curve starting with 0 and ending with 1. 6. Insert the Divide Curve component. 8. Edit the Slider values: Under Slider accuracy, set Integer Numbers. Under Numeric domain, set 1 as the Min and 20 as the Max. 9. Connect the components: Crv output connects to the C input on the Divide Curve component; Slider output connects to the N input on the Divide Curve component. [The first connection tells the Divide Curve component what curve to divide; the second connection tells the Divide Curve component how many divisions to make.] 10. Insert the Circle CNR (Center-Normal-Radius) component. 11. Connect the components: P output on the Divide Curve component connects to the C input on the Circle CNR component; T output on the Divide Curve component connects to the N input on the Circle CNR component. [The first connection tells the Circle CNR component to draw circles centered at each of the division points; the second connection tells the Circle CNR component to “tilt” the planes on which circles are drawn to align with the Rhino curve.] 13. Connect the components: C output on the Circle CNR component connects to the C input on the Loft component. [This connection tells the Loft component to create a surface using the circles as “ribs.”] 14. Insert the Graph Mapper component and another Number Slider. 15. Right-click on the Graph Mapper component. From Graph types, choose SinC. 16. Edit the Slider values: Under Numeric domain, set 1 as the Min and 50 as the Max. 17. Insert the Multiplication component. 18. Connect the components: t output on the Divide Curve component to the input on the Graph Mapper component; output on the Graph Mapper component to the A input on the Multiplication component; output on the Slider to the B input on the Multiplication component. [These connections produce a list of numbers which is then multiplied by the output of the Number Slider. The list of numbers is determined by the y-coordinates of the graph in the Graph Mapper corresponding to the given x-coordinates (i. e., the inputs to the Graph Mapper).] 19. Connect the components: R output on the Multiplication component to the R input on the Circle CNR component. [This connection tells the Circle CNR component to draw circles at radii corresponding to the output of the Multiplication component.] 20. The Grasshopper definition is complete. Experiment by (1) selecting different curves from Rhino; (2) changing the number of divisions (first Number Slider); (3) changing the shape of the graph in the Graph Mapper component (move the grips); (4) changing the graph type in the Graph Mapper component; (5) changing the multiplication value (second Number Slider).

# Step-by-Step: Basic Mathematics in Grasshopper

1.   Start Rhino; maximize the Top view; type Grasshopper at the Command prompt.
2.   In Grasshopper, choose File > New Document.
3.   Double-click anywhere in the Grasshopper canvas to search for the Number Slider component.
4.   Insert a Number Slider into the Canvas. 5.   Double-click on the label of the Slider component to edit its properties.
6.   Under Numeric Domain, set the “Max” value to 100. 7.   Click OK.
8.   Single-click on the Slider and copy it to the Clipboard (ctrl-C).
9.   Paste the Slider (ctrl-V). 10.   Arrange the two Sliders vertically. 11.   Double-click anywhere in the Grasshopper canvas to search for the Addition component. 12.   Insert the Addition component into the Canvas. 13.   Repeat the previous two steps with the Subtraction, Multiplication, and Division components. 14.   Connect the first Slider to the “A” inputs of the components. Notice that the Slider automatically updates its label to “A”. 15.   Repeat the previous step with the second Slider and the “B” inputs. 16.   Double-click anywhere in the Grasshopper canvas to search for the Panel component.
17.   Insert a Panel into the Canvas. 18.   Single-click on the Panel and copy it to the Clipboard (ctrl-C).
19.   Paste the Panel three times (ctrl-V).
20.   Arrange the four panels vertically. 21.   Connect the “R” (result) outputs from the Addition, Subtraction, Multiplication, and Division components to the inputs on the panels. 22.   The Grasshopper definition is complete. Experiment with adjusting the two sliders and observe the results.

# Step-by-Step: A Simple Grasshopper Definition

Creating Grasshopper definitions is rarely a straightforward, linear process. It usually involves having a general idea of what one wants to accomplish, and a sense of which components will be necessary; however, the process almost always involves extensive testing, false starts, discoveries, and iterations along the way.

As an example, consider creating a Grasshopper definition which can create elliptical towers: One way of creating this definition is shown in the following step-by-step procedure.

1. Start Rhino; type GRASSHOPPER to start Grasshopper.

2. Double-click in the Grasshopper canvas to search for and insert the Ellipse component (or Curve > Primitive > Ellipse). Notice that when the component is placed on the Grasshopper canvas, it is automatically previewed in Rhino, on the basis of its default values: To see the component’s default values, hover the mouse over the input labels (P, R1, and R2). P, the base plane, is by default the XY plane and is previewed as a red grid in Rhino. R1 and R2, the ellipse’s two radii, are be default both set to one (1.0). Their result is previewed as a red circle in Rhino.

However, we want the component to produce variable-sized ellipses. Therefore, we need to introduce variable input in the form of number sliders.

3. Double-click in the Grasshopper canvas to search for and insert the Number slider component (or Params > Input > Number Slider). 4. Double-click on the label of the number slider (“Slider”) to adjust its values as shown below: This will allow the slider to generate values between 0 and 50, with a precision rounded to three decimal points. Its initial value is set to 10, but that value is variable.

5. Copy and paste the first slider to create another slider. Double-click on this slider and change its name to Radius 2. 6. Connect the two sliders to the Ellipse component by dragging wires between them. Begin by clicking on the slider output node, hold down the mouse button, and release it on the input node of the Ellipse component. Notice how this affects the Rhino preview: The ellipse is now shown with radii of 10 units. Adjust the number sliders to see how the preview is affected.

7. Having created a base ellipse of variable size, we now need to begin stacking multiple copies of the ellipse. We’ll do this by copying the ellipse vertically. Grasshopper does not have a Copy component; instead, we use the Move component — with the knowledge that the original ellipse will still preview in its original location.

Double-click in the Grasshopper canvas to search for and insert the Move component (or Transform > Euclidean > Move): The Move component requires two forms of input, which you can see by hovering the mouse over the input labels (G and T). Input G (Geometry) requires a drawn or modeled object — such as an ellipse. Input T (Motion, or Translate) requires a direction/magnitude in the form of a vector. Notice that by default, input T is set to a vector 10 units long in the Z-direction (0.0,0.0,10.0).

8. Connect the E output on the Ellipse component to the G input on the Move component: Notice how this affects the Rhino preview: A new ellipse is previewed 10 units vertically above the original ellipse.

However, we need multiple ellipses, placed at a variable distance (i. e., floor-to-floor height) above the original ellipse. We will need to do something different for the T input on the Move component. Specifically, we will need to provide to this component as input a list of numbers corresponding to the vertical positions of the floors.

9. Double-click in the Grasshopper canvas to search for and insert the Series component (or Sets > Sequence > Series): The Series component generates a list of numbers according to input parameters. Hover the mouse over the input labels (S, N, and C) to find out what is required for input.

The S input requires a single number, the start of the list. Assuming we want the first floor of our tower to be on the XY plane, S can be set to 0 (zero). The simplest way to do this is to right-click on the S label and choose Set Number from the dropdown menu. (Note that by default, S is already set to zero.)

The N input refers to the step size — the floor-to-floor height. And the C input refers to the count of items in the list — simply, the number of floors in the tower. Both N and C can be controlled with number sliders.

10. Insert two number sliders with the following values (note that Number of Floors is set to Integer rounding): And then connect the sliders to the Series component as shown below: 11. Hover the mouse over the S output on the Series component. You should see the list of numbers generated in accordance with the input values. Now, it would seem that we could simply connect the S output from Series to the T input on Move — but if we do this, Grasshopper will generate an error message at the Move component: The problem is that the Move component expects vectors as input at T; we have given a list of numbers, not vectors. To fix this, we need to insert a Unit Vector component between the Series and Move components.

12. Double-click in the Grasshopper canvas to search for and insert the Unit Z component (or Vector > Vector > Unit Z): 13. Reconnect wires as shown below (note: you can manually disconnect wires by right-clicking on input or output nodes and selecting Disconnect): Once again, notice how this affects the Rhino preview: Adjust all four number sliders to see the effect on the Rhino preview.

14. That completes the basic definition. Additional steps might include:

Extruding the floors to a specified or variable thickness (as shown in the image at the beginning of this post);

Varying the elliptical radii along the height of the tower;

Constructing a “skin” on the tower.

# Grasshopper: Components

Grasshopper components are the building-blocks of Grasshopper definitions.

When a component is initially placed on the Grasshopper canvas, it usually looks something like this: A component’s color indicates information about its behavior. An orange component indicates that the component needs input before it can perform an action. In the example shown above, the BoxRec component (which constructs a rectangular box) needs input in the form of a rectangular base and a height. A red component has generated an error. A white/gray component is functioning normally.

Many (not all) of the Grasshopper components equate to Rhino modeling commands. A good working familiarity with Rhino is necessary to fully understand Grasshopper components. Several Grasshopper components (such as “number sliders”) do not have Rhino equivalents but are used to control or modify parameters within a definition.

Almost all components have input and output nodes. Input nodes (on the left side of a component) are used to supply the component with input — such as a number, or a list, or a Rhino object. Input can be provided with a wire from another component, or in some cases, by right-clicking on the input node, or on the component itself, to set a value. Output nodes (on the right side of a component) are used to send information to other components.

Panels are a special kind of component, which look like this when initially placed: A panel is generally used in one of three ways. First, it can simply be used as an annotation or note on the canvas, with no wires connecting it to anything else. Or, if its contents are appropriately edited, it can be used to supply input (such as a single number) to a component. Finally, if its input node is connected to another component’s output node, it simply displays in textual form whatever information the previous component is generating. In this case, the panel simply acts as a flow-through with no effect on the data displayed.

TO PLACE A COMPONENT ON THE CANVAS:

Do either of the following:

1. Double-click in a blank space on the canvas to bring up a search box. Type a few letters of the component you wish to place, and choose from the resulting menu. (For example, typing BOX will bring up a menu including BoxRec.)

Or:

2. Navigate to the component using the tabs across the top of the Grasshopper window (“Params”, “Maths”, “Sets”, etc.). After locating the component, drag it into the canvas.

TO CONNECT COMPONENTS USING WIRES:

Use the mouse to drag from a node on one component to a node on another component.

Note that some (not all) components allow multiple wires. Hold down [shift] to enable multiple connections from a single node.

TO DISCONNECT A WIRE:

Right-click the component near the node you wish to disconnect. Choose Disconnect from the dropdown menu.

TO MOVE A COMPONENT OR A GROUP OF COMPONENTS:

Select components singly or in a group by dragging a window around them. Move them by dragging them, once selected. Connecting wires will stay connected during moves.

TO PREVIEW THE EFFECT OF A COMPONENT IN RHINO:

By default, the effect (if any) of a component is previewed in the Rhino modeling environment using the color red. To disable the Rhino preview of a component or a group of components, select the component(s), click the space bar, and click on the “masked head” icon. To re-enable preview, repeat this action, except click on the “unmasked head” icon.

# Grasshopper: Definitions

A Grasshopper definition consists of a series of components connected by wires. This image shows a typical definition with components and wires: Grasshopper definitions are always read from left to right.

Definitions always have a mechanism for input. Input can be in the form of Rhino objects, or it can be in the form of numbers. In the example shown above, input is provided by adjusting the three number sliders.

Reading from left to right, input feeds into components along wires. Components typically perform some action, which could involve performing calculations or constructing objects in Rhino. In the example shown above, the Rectangle component creates a rectangle in the Rhino modeling environment, using as input the “X Size” and “Y Size” numbers set by the number sliders. Similarly, the BoxRec component creates a rectangular box in Rhino, using as input the rectangle constructed by Rectangle, and the “Height” number set by the number slider.

Thus, Grasshopper definitions have output which is typically in the form of potential Rhino objects. These potential Rhino objects become actual Rhino objects only when Grasshopper’s Bake command is applied within the definition. To Bake a definition, right-click on a component’s output node (on its right side), and select Bake.