[Grasshopper] How to use Member Index to obtain index numbers that match specified item names

[Grasshopper] How to use Member Index to obtain index numbers that match specified item names Grasshopper component EN

This article explains how to use Member Index to obtain index numbers that match specified item names.

Member Index1
Member Index2

On the Grasshopper, it is represented by either of the two above.


↑Youtube Channel

Obtaining index numbers that match specified item names

Member Index can be used to obtain index numbers that match specified item names from within a list.

Obtaining index numbers that match specified item names

The Member Index(S) is a string of data.

In this case, six English fruit names are prepared at random.

In the Member Index(M), connect a string of item names corresponding to the index number you wish to extract.

In this case, we want to extract the index number of Apple, so we enter Apple.

Then, the Member Index(I) outputs the index number of the item that matches the specified item name.

This time, Apple is specified, so the Apple index number of the fruit name data is extracted.

The Member Index(N) also outputs the numerical value of the number of items extracted.

In this case, 2 is output since the data is extracted from 2 Apple.

Note that Member Index only works with strings

Note that Member Index only works with strings.

In the image above, we are trying to extract the index number of the number 2 from a random number.

However, this will not work with direct numerical information such as a Number Slider connected to the Member Index(M).

Panel
Panel2

Therefore, you can input the numerical value as a string into a Panel or other device, or you can convert the numerical information into a string by passing it through the Panel.

Components used
Click to Zoom

Components used: (1) Random ( 2 ) Integer (3) Member Index

Not only the M, but also the S must be converted to a string.

In the image above, we are trying to create 5 random 0~10 numbers and extract the index number of 4.

Input the numerical value range information of 0 To 10 to the Random(R).

Input the number of pieces, 5, to the Random(N).

Connect Random to Integer in order to round the output number from a decimal point to an integer.

Then, connect the Integer to the Member Index(S).

However, the result is not reflected because numerical information is input to the Member Index(S) instead of a character string.

through Panel
Click to Zoom

So, put a Panel between Integer and Member Index and converted it to a string.

.

Example Usage of Member Index

Let’s look at an example of Member Index usage.

This time, we will try to move multiple points directly above each other using randomly generated numbers, and extract only the points with the specified numerical height.

Example Usage of Member Index
Click to Zoom

Used components: (1) Rectangle ( 2 ) Surface (3) Divide Surface ( 4 ) Random (5) Integer (6) Unit Z ( 7 ) Move (8) Member Index (9) List Item

Rectangle

First, input 100 to the Rectangle(X and Y) to create a 100 x 100 square line data.

Surface

Connect the Rectangle(R) to Surface to convert it to a surface.

Divide Surface

Connect the Surface to Divide Surface(S).

Input 10 to the Divide Surface(U and V).

The surface is now created with 100 10 x 10 points.

Flatten

At this point, right-click on the Divide Surface(P) and set it to Flatten.

move points

Then, set the value of the Random(N) to 100 as described earlier.

This will create 100 random numbers 0~10.

Then, connect the Integer to Unit Z.

Connect Unit Z to the Move(T).

Connect the Divide Surface(P) to the Move(G).

Then, 100 random numbers are reflected in the 100 points created, and they move in an upward direction.

only the point with the specified height 4 could be retrieved

Then, connect the Move(G) to the List Item(L).

Connect the Member Index(I) to the List Item(i).

Then, since the index numbers of the 100 moved points are the same as those of the 100 random numbers, only the point with the specified height 4 could be retrieved.

This is a view from the side

This is a view from the side.

List of Grasshopper articles using Member Index component↓

Comment

Translate »