3.5. Data

Introduction to Data in Grasshopper.

Data Trees extended:

Download example file for Data Trees (extended):

GH File

Data Structure in GH

We can subdivide data structure into 3 different groups in GH:

  • Single
  • List
  • Tree
Data structure

Elements to consider

  1. Lists
  2. Index
  3. Items
  4. Paths
  5. Branches
  6. Data Tree

Lists

A List is an ordered (but not necessarily sorted) collection of data. Lists may contain zero elements, a single element, or many elements. The same element can occur more than once in the same list, and different elements with identical values. Also, a list may contain empty elements, referred to as nulls.

When storing data in a list, it’s important to know the position of the items in that list in order to access or manipulate them. The position of an item in a list is called Index Number.

Lists

Data Tree

It is important to understand how large quantities of data are stored, accessed, and manipulated.

A Data Tree is a hierarchical structure for storing data in Nested Lists or Sub-Lists.

These nested sub-lists work in the same way as folder structures on your computer in that accessing indexed items require moving through paths that are informed by their generation of parent lists and their own sub-index.

Data Tree I

Difference between List (Flatten) and Data Tree (Graft):

Data Tree II

List Visualization

We can visualize the Indices and Items in different ways in order to understand and manipulate them:

Point List

Displays the Index Item Number next to the point geometry in the viewport.

Point list I

Text Tag

Draws strings as feedback items. When text tags are baked into the scene, they turn into Text Dots.

List textag I

Tree visualization

Params > Util > Param Viewer

Param viewer

Color

We can visualize the data of a list by assigning color to it. You can find it on Params > Input > Gradient.

The L0 value represents the low end (left side) of the gradient, whereas the L1 value represents the upper end (right side). These values correspond to the Start and End of our domain. The t-values are the elements in the list that will get mapped somewhere within the L0 and L1 range.

The output of the gradient is a list of RGB color values which correspond to each point in our list.

List color I

Knowledge Checks