Advanced Grasshopper Topics

Numeric Parameters

  1. Open a new Grasshopper file.
  2. Insert a Sets > Sequence > Sequence component and examine its input arguments.
  3. The default list length L is 20. Suppose we want to change this to 24. There are three ways to do it:
    1. Right click on the L and do "Set one number".
    2. Create an Integer component, set its value to 24, and connect it to the L input of Sequence.
    3. Create a panel, double click on it, type "24" in the panel, and click outside the panel to complete. Then resize it.
    The benefit of the last method is that the parameter value is visible all the time, so we don't have to hover to see it.
  4. Hover over the I parameter and note that it contains two values. To put this data into a panel, we put one value on each line, and click on the "Multiline Data" option in the panel settings.
  5. Here's an atlernative approach: right click on the I parameter and choose "Extract parameter". This creates a number component.
  6. Create a panel and connect the number component to its input. Connect the output of the panel to the I input of Sequence.
  7. Connect a panel to the output of sequence and verify that it contains the first 24 Fibonacci numbers.
  8. Right click on the panel and play with the Draw Paths and Draw Indices settings.
  9. Change the values in the number parameter from 1,1 to 3,5.
  10. Right click on the I input to the Sequence component and choose "Internalize data".

  11. Exercise: How would you use a Sequence component to create a list of powers of 2?

Groups

  1. Groups offer a way to visually group parts of your computation to improve readability.
  2. Click and drag to select all the components on the sheet.
  3. Right click on an empty spot withing the selection rectangle and choose "Group".
  4. Right click inside the group to bring up the context menu, and type a label for the group in the edit box at the top.
  5. Right click on the group and try experimenting with the box, blob, and rectangle outline views by moving components around.
  6. Create a panel above your Fibonacci computation and type "Fibonacci" as the panel contents.
  7. Right click on the panel, go to Font Settings, and set the font size to 18.
  8. Right click on the panel again, go to Color, and set the color to some shade of orange.
  9. Click on the panel to make sure it's selected, then right click within the group and choose "add to group".

Expressions

In this section we're going to create a sunflower pattern using a "golden angle" of 360 degrees times (1 - 1/φ), where φ is the golden ratio defined as (1 + sqrt(5))/2.

  1. Create a Sets > Sequence > Series component and set it to produce integers from 1 to 1000. Use a panel to specify the C value of 1000.
  2. Feed the output of the Series commponent into a Square Root component.
  3. Create an Expression component.
  4. Double click on it to edit the expression, and set the expression to x-1.
  5. Connect the output of the Series component to the x input of your Expression component. Leave y unconnected.
  6. Zoom in on the Expression component until the + and - signs appear. Use the - sign to eliminate the y input.
  7. To generate the golden angle, create an Expression component and set the expression to 2*pi*(1-1/phi).
  8. Zoom in on the Expression component and delete the x and y inputs.
  9. Run the output of the Expression component into a Math > Trig > Degrees component and verify that the value is roughly 137.5 degrees.
  10. Create a Multiply component. Connect the "x-1" Expression output to the A input of the Multiply, and the value of the phi Expression (in radians) to the B input of the Multiply.
  11. Run the output of the Multiply component into Sin and Cos components.
  12. Insert two additional Multiply components and feed the Sin and Cos outputs to their B inputs. Feed the output of the Sqrt component to their A inputs.
  13. Create a Vector > Point > Construct Point component.
  14. Feed the outputs of the two Multiply components into the x and y inputs of Construct Point.
  15. Create a Curve > Primitive > Circle component.
  16. Use a Panel to set the R input of the Circle component to 0.75.
  17. Connect the output of Construct Point to the P input ofthe Circle component.
  18. Click on the Circle component so the circles are selected (green in Rhino) and the points are not (red in Rhino).
  19. Enjoy the lovely sunflower pattern.

Clusters

Clusters are a way of abstracting a Grasshopper computation so that it can be used in multiple places. Basically, clusters are Grasshopper subroutines.
  1. Create a new file.
  2. Insert a Surface > Primitives > Sphere component.
  3. Insert a Surface > Util > Divide Surface component and connect the Sphere to its S input.
  4. Flatten the P output of Divide Surface.
  5. Create two Sets > Sequence > Cull Index components. Run the output of Divide Surface into both their L inputs.
  6. Set the I parameter of the first Cull Index component to -1, meaning we will delete the last element of the list.
  7. Set the I parameter of the second Cull Index component to 0, meaning we will delete the first element of the list.
  8. Insert a Curve > Primitive > Line component and Run the outputs of the two Cull Index components into its A and B inputs.
  9. Observe the results.

  10. Now we're going to make this into a cluster so we can use it as a component in other programs.
  11. Create a Cluster Output component by typing space to get a search box and then typing "Cluster Output".
  12. Run the output of the Line component into the Cluster Output component.
  13. Delete the Sphere component.
  14. Create a Cluster Input component and run it into the S input of Divide Surface.
  15. Click and drag to select all components.
  16. Right click within the selection and choose "Cluster".
  17. Right click on the cluster and choose "Export". Save your cluster as "MakeLines".
  18. Open a file browser and locate the file you created. It's a .ghcluster file.

  19. Create a new file in Grasshopper.
  20. Insert a Surface > Primitive > Cone component.
  21. In the file browser, click on the MakeLines file and drag it onto the Grasshopper canvas. Notice that the parameter names are reset.
  22. Connect the Cone to the S input of MakeLines.
  23. Observe the results.
  24. Double click on the cluster component to open and edit it.
  25. Click on the open cluster icon in the top left corner to close the cluster edit.

Hidden and Faint Wires, and Relays

Use invisible wires to declutter your display.
  1. Insert a Params > Geometry > Point component.
  2. Right click on it and do Set one point. Draw the point in Rhino.
  3. Right click on the Point component and set its name to Banana.
  4. Use the icon next to the name to change the display mode so that the name is shown instead of the icon.

  5. Create another Point component far away from the first one. Set its name the same way as the previous one.
  6. Connect the first Point component to the second. Now we have along wire cluttering up the display.
  7. Right click on the second Point component, go to Wire Display, and choose Hidden. Now the display is decluttered.
  8. Create a Sphere component and connect the output of the second Point component to its B input.
  9. Right click on the B input to Sphere, go to Wire Display, and choose Faint. This is useful when you still need to see the wires but you don't want to call attention to them.
  10. Create a BoundingBox component and connect the output of the Sphere component to its input.
  11. Double click on the wire between Sphere and BoundingBox. This inserts a Relay component, which allows you to have finer control over the wire routing.
  12. Right click on the Relay component and give it a name.
  13. Double click on one of the wires attached to the Relay (either its input or its output to insert another Relay.
  14. Double click on a Relay component to delete it.

Dave Touretzky