Grasshopper Lists and Trees

Grasshopper Uses Typed Lists

  • A point is not a list (of numbers): it's a Point object.

  • Grasshopper expects the inputs to components to be "collections", which are trees. In the simplest case this is a single flat list. If a component takes a Point argument, it's really looking for a collection of points. A single Point is treated as a list of length one.

  • A terminal node in the Param Viewer tree represents a list of values, not a single value. So a simple list of three points is drawn as a tree with one terminal node.

  • In the path notation, the numbers refer to links in the tree, not nodes. The root is {}. A flat list by is normally {0}, and is depicted as a tree with one branch. It's possible to construct a list whose sole path is {1} or {2}, but this is not usual.

  • The Line component needs two points; if its A and B inputs are both lists, it iterates over them in parallel, using Longest by default so the last item in the shorter list gets repeated.

  • Argument enumeration is recursive, so if input A is a list of points, and input B is a single list of a list (from Graft), then for each A point it has to iterate over the B list (because the sole B list item is being repeated), and we get a cross product.

  • Use Display > Selected Only Preview to more conveniently examine the contents of individual components.

Argument Enumeration

  1. Make two Param > Point components.
  2. Right click on each one and choose "Set one Point". Put the second point to the right of the first one and slightly above.
  3. Insert a Curve > Primitive > Line object and connect the points.
  4. Right click on the Point components and choose Set Multiple Points. Set the first component to 3 points and second to 4 points.
  5. Notice that if GH runs out of values, by default it repeats the last one.
  6. Try the Shortest component.
  7. Try the Cross Reference component to get an outer product ("holistic").
  8. Graft one tree to generate a cross product.
  9. Explain graft and flatten.
  10. Show Parameter viewer, double click on it to switch to Draw Tree mode.

A Video Tutorial on Grasshopper Data Trees

If you want to see more material on this subject see this YouTube video, Grasshopper Lecture 4: Data Trees, Structure.

Dave Touretzky