GS Script. Simple Data Sorting.
by vlad_molch in Design > 3D Design
16 Views, 0 Favorites, 0 Comments
GS Script. Simple Data Sorting.
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
Laptop or desktop computer
Rhino 8
Grasshopper
Algorithms-Aided Design: Parametric Strategies Using Grasshopper by Arturo Tedeschi
Sorting by "if/then"
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.
Text Example "If/Then"
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.
Find One
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.
Find Geometry
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.
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.