GS Script. Simple Data Sorting.

by vlad_molch in Design > 3D Design

16 Views, 0 Favorites, 0 Comments

GS Script. Simple Data Sorting.

Artboard 1.png

In this Instructable, we will explore Grasshopper operations through examples that sort data based on conditions. We will use if / then logic to define different outputs when a condition is met, and Contains to identify specific geometry within a larger set.

Supplies

Screenshot 2026-06-24 120822.png

Laptop or desktop computer

Rhino 8

Grasshopper

Algorithms-Aided Design: Parametric Strategies Using Grasshopper by Arturo Tedeschi

Sorting by "if/then"

Screenshot 2026-06-24 121224.png

The first step is to understand the basic structure Grasshopper uses to sort data: how to write a function with variables and produce an output.


GS Script download

Text Example "If/Then"

Screenshot 2026-06-24 121142.png

In this example, a text value is used to demonstrate that the output of a condition is not limited to numbers. When the condition is evaluated, Grasshopper can return any type of data, including text, which can then be sorted or processed further based on the result.


GS Script download

Find One

Screenshot 2026-06-24 121440.png

In this example, we search a list of numerical variables to check whether a specific value is included. This becomes useful when working with longer lists, where Contains can quickly identify whether the data set includes the value we need.


GS Script download

Find Geometry

Screenshot 2026-06-24 121537.png
Screenshot 2026-06-24 121546.png

This step applies the same Contains logic to geometry. A group of referenced geometries is passed into Grasshopper, and the script checks the input set to find the needed geometry type. It works the same way as the previous number example, but uses geometry descriptions instead of numerical values.

Note: Grasshopper identifies referenced geometry using specific text descriptions displayed in the Panel. Understanding these names can be useful for future sorting operations, since Contains searches for text patterns rather than visual objects. To find a particular geometry within a larger data set, you first need to know the description Grasshopper uses to identify it.


GS Script download

Conclusion

Through a series of simple examples, we explored how Grasshopper sorts and evaluates data using the Evaluate Function and Contains components. These workflows demonstrate both conditional and specific methods of filtering information based on input values and desired outcomes. In this lesson, we applied these principles to numerical data and geometry to better understand how data can be identified, sorted, and used within a Grasshopper definition.


GS Script download