This article explains how to use the List Item component to extract data by specifying an index number.


On the Grasshopper, it is represented by one of the two above.
How to use the List Item component
By using the List Item component, you can extract data by specifying an index number.
Extract a single piece of data

This is the most basic usage.
The data used in this case contains 0~900 Item data for each Index number from 0~9.
Connect the original data with all values to the List Item(L).
Then, connect the Index number of the data you want to obtain to the List Item(i).
In this case, we want only the number 300 among the Items, so we use Index number 3.
Then only 300 data will be output as a result.
Extract Multiple Data

If you want to extract multiple Items, you can do so by connecting multiple numbers to the List Item(i) and specifying multiple Index numbers.
This time, Index numbers 3 and 7 are specified.
Then, only the numbers 300 and 700 corresponding to Index numbers 3 and 7 are retrieved.
After the last Index number, we go back to the beginning

Although the Index number is specified as 10, the actual data contains only Index numbers up to 9.
In that case, it returns to the first Index number 0.
In fact, the output result is 0.
Specify the Index number from the back
Index numbers can also be specified from behind.

This Negative component is used for this purpose.
This component will convert a number to a negative value.

Thus, using the Negative component, the number is converted from 2 to -2.
Connecting the negative number to the i terminal specifies the Index number from the back.
In this case -2, so the second 800 from the back is output as the result.
Obtaining the before and after of a specified Index number
Obtains the before and after of a specified Index number.

When zoomed toward the List Item component, the + symbol appears.

Clicking on them created these up and down -1 and +1 terminals on the right side.

In this case, we specified Index number 5, but now we can get not only 500, but also 400 and 600 for Index numbers 4 and 6 before and after.

More terminals can be added in this way.
List of Grasshopper articles using the List Item component↓
Comment