Managing data in Grasshopper I

Managing data in Grasshopper can be a challenge. Grasshopper allows a user to generate a lot of data easily, making it a powerful design tool. However when so much data is created, its organization becomes a problem. Grasshopper solves this by structuring the data into items, lists and trees. I found that for many users, me included, it is difficult to understand how these data structure are manipulated. For this reason, I taught a quick tutorial on data handling to the students of Module II at the Future Cities Lab.

The process of explaining and answering students' questions helped me to understand these concepts more clearly. I am posting the tutorial here in the hope that it might be useful for some of you readers as well . It is broken down into 4 parts and concludes with an exercise. The first 3 parts will be covered in this post and the remaining content in in a subsequent post.

I have chosen to concentrate on text manipulation in all these examples. Part 1 and 2 concentrates on lists. A list is an ordered collection of items and each item has an index. Lists are mutable: items can be inserted, deleted or replaced, lists can be split and reversed. In Grasshopper, lists are created automatically when multiple wires go into an input (hold the shift button to add items); they are represented as double line wires.

Part 1 is a simple example that illustrates the different between shortest list, longest list and cross-reference. These options pop up when you right-click on a component (concatenate component here). By default, Grasshopper will use the longest list option. Cross referencing means that each data item in  list A will be matched with every other item in list B. One useful application of this is in the creation of grids.

Tutorial part 1

Tutorial part 1

Part 2 shows looks at some ways to manage lists. I have chosen 4 components from the 'List' tab as examples: Split, Dispatch, Pick and Choose, and Weave. The split and dispatch components separates a list into two. Dispatch uses a pattern to separate the list. Here it is a repeating True-False pattern. Patterns (P) are also used for the Pick and choose, and Weave components, to the determine the sequence in which the data streams are read. One way to understand the difference between the two components is that Pick and Choose will only 'choose' one of the data items at a time. In this case only 1st item from data 0, only 2nd item from data 1 (in this example of a patern 0-1-2). Weave will re-organize all the data in the order specified. So it is 1st item from data 0, data 1 and data 2; then 2nd item from data 0, data 1 and data 2 .... There P 'n' C will end up with less data items than a comparative weave component.

Tutorial part 2

Tutorial part 2

Part 3 introduces the data tree, which is a hierarchical structure. Working with trees is trickier than lists, but Grasshopper provides a set of components for working with them. 3 things to note with this example, beginning from left to right. For the bottom 2 weave components, an upward arrow is shown next to the data item - this means we have chosen to graft the data item. Graft means that a branch is created for each data item. For example, a flat list with 3 items becomes a tree with 3 branches (of 1 item) after grafting. A tree is visually represented as a dotted line. Secondly, the 3 gray panels towards the right are param viewer components; they are invaluable for working with trees as the structure can be visualized. Finally the last three components on the right show different ways of accessing data. A item from a list can be retrieved with an index integer, a branch from a tree can be retrieved using a path (this is written as number enclosed by curly braces e.g. {1}), and an item from a tree requires both path and index information.

Tutorial part 3

Tutorial part 3

Part 4 will touch on data trees more. Meanwhile the definition can be downloaded here.

/