3.5. Data
Introduction to Data in Grasshopper.
Data Trees extended:
Download example file for Data Trees (extended):
GH FileData Structure in GH
We can subdivide data structure into 3 different groups in GH:
- Single
- List
- Tree
Elements to consider
- Lists
- Index
- Items
- Paths
- Branches
- 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.
Points
, Curves
, Surfaces
, Meshes
, etc…
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.
Difference between List (Flatten) and Data Tree (Graft):
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.
Text Tag
Draws strings as feedback items. When text tags are baked into the scene, they turn into Text Dots.
Tree visualization
Params > Util > 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.