3.6. Data Operations

Data operations in Grasshopper

Data Operations

Data operations can happen at different levels:

  • Single level
  • Lists level
  • Tree level

Single level operations

Many components operates on individual values and also output individual values as result:

1:1

Lists level operations

Other category of components create lists of data from single input values:

1:N Occurring also the opposite behavior: N:1

Many components only operates on lists of data and also output list of data:

N:N

Tree level operations

Some few components output several list points, each of them representing a row or column in a grid:

1:N'

We can also access to specific items in the Data Tree:

N':1

Or we can just operate them keeping or modifying its Data Tree structure:

N':N'

List Manipulation

Most of the operation in Grasshopper will happen at List level and Grasshopper is specially good at quickly building and manipulating lists of data.

Range

List of equally spaced numbers between a Low and a High value is called Domain. A domain is every possible number between two numeric extremes.

The Range component divides a numeric domain into even segments and returns a list of values.

  • Sets > Sequence > Range
Range

List Length

Measures the length of the List.

  • Sets > List > List Length
List length

List Item

To find a specific data item from within a list.

When accessing individual items in a list, we have to specify the Index Number we would like to access, that can be a single integer or a list of integers.

  • Sets > List > List Item
List item

Reverse List

To invert the order of the list.

  • Sets > List > Reverse List
List reverse

Shift List

We can move the list index up or down depending on the value of the shift offset.

If we set the “Wrap” value to False, we will remove the last value. However, if we set the “Wrap” value to True, the first entry will be moved to the bottom of the list.

  • Sets > List > Shift List
List shift

Insert Item

Insert a collection of items into a list.

You need to know the items you want to insert and the index position.

  • Sets > List > Insert Item
List insert

Cull Pattern

Removes elements in a list using a repetitive pattern.

The pattern is defined as a list of Boolean values (True or False).

  • Sets > Sequence > Cull Pattern
List cull

Flatten tree

Flatten removes all levels of a Data Tree, resulting in a single List.

  • Sets > Tree > Flatten Tree
Flatten

Graft Tree

Graft Tree creates a new Branch for every Data Item.

  • Sets > Tree > Graft Tree
Graft

Simplify tree

Simplify a data tree by removing the overlap shared amongst all branches.

  • Sets > Tree > Simplify Tree
Simplify

Flip Matrix

Flip Matrix component Swaps the “Rows” and “Columns” of a Data Tree with two Path Indices.

  • Sets > Tree > Flip Matrix
Flip

Comparison operators

Comparison operators are used to compare values.

They return Boolean values based on whether a comparison is True or False.

  • Maths > Operators

Booleans

Boleans variables can only store two values:

  • TRUE (1)
  • FALSE (0)
Comparators

Boolean Toggle allows you to quickly change between single True or False values:

Comparators

Grasshopper has components to test conditions and output Boolean values:

Comparators

Check if a number is contained inside a certain Domain:

  • Maths > Domains > Includes
Comparators

Logical operators

Logical operators mostly work with Booleans.

Gate NOT performs boolean negations.

  • Maths > Operators > Gate NOT
Comparators

AND and OR components takes two arguments as input. Logical operators are used to evaluate something.

  • Maths > Operators > Gate AND
Comparators

Different combinations:

  • Maths > Operators > Gate OR
Comparators

Knowledge Checks