1st March 2024

GHEC 04 : Grasshopper Data Structures

Today's focus

  • Grasshopper data types
  • Homework

Grasshopper Data Structures

There are three types of data structures in Grasshopper:

  • Item - The simplest form, representing a single piece of data.
  • List - An ordered collection of items.
  • Tree - Essentially, lists within lists, offering a hierarchical structure for managing complex data sets.


An Item is a single unit of data that you pass in and out of components in Grasshopper. It's the data structure that we have been working with the most.

Pasted image 20240122090214.png


We have been working with lists when we created the twisted tower. But in case you miss it, here is what a list looks like

Pasted image 20240122090347.png

Note: If you noticed, there are now double-line wires instead of single line. That tells you that the data being passed in/out is a list

List Indices

To access individual items of a list, we can use indices. Indices are like addresses for the items and are normally in a numerical sequence (i.e. 0,1,2,3,4,.....)

Pasted image 20240122093150.png

If we want an item from the list, we have to know the "address" (index) of the item. The List Item component lets us access the items in the list using its index.

List item 1.gif

I like the analogy of houses and addresses. Say you want to find John Smith in a row of houses. You need to first get his address, the index, before you can get to him.

This is how I think about accessing the data :

Pasted image 20240205101232.png


One of the hallmarks of Grasshopper is it's ability to handle complex data. It does this with the use of data trees. You can think of a tree as lists inside lists and is infinitely recursive. i.e. you can have a list within a list within a list within a list ..... and so on.

Pasted image 20240122090540.png

Tree Anatomy

Much like lists, trees also have addresses but because they are infinitely recursive, their "address" is also more complicated. These "addresses" are known as paths.

To get to a list in a tree, you need to use a path to get there. Then, once you're in the list, you can use an index to get to your item.

Pasted image 20240122094606.png

Similar to how you can use 0,1,2,3,... to access items in a list, you can use {0;0;1} in this example to access the first list in a tree.

Path Anatomy

Going back to the address and house analogy. Paths are addresses for trees. and if you think of indices as the street number, think of paths as the street name and postcode of the address.

Paths follow the convention of {a;b;c;d;....} where a,b,c,d are known as branches.

Pasted image 20240122095043.png

These branches are what allow you to add an infinite amount of lists into a tree. While straightforward in concept, trees can be quite complicated to use. So, it's okay if you don't understand everything the first time. You can always refer back to this session at anytime.

And visually, this is how I think about accessing the data.

Pasted image 20240205101750.png

Today's Homework

Remember the double-twisting tower homework from session 2? Now, I am going to challenge you to make the same model but using trees instead.

To help you, I have taken my solution from before and added some notes to guide you through how to add trees.

​Session 04: Double Twisting Tower with Tree Hints​

Note: This challenge will be especially difficult.

Final Thoughts

I know today's session can be overwhelming. I want you to know that it is completely normal and to take your time processing the information.

Learning data structures is like learning how to drive for the first time, everything is overwhelming and there is just too much information to process at once. But after some time and experience, the information becomes second nature.

The homework for this lesson will help you get started but dedicating time to practice and explore will be the key to mastering this skillset.