This article explains how to use Dispatch for conditional branching and retrieving odd/even indexed data.


On the Grasshopper, it is represented by either of the two above.
Retrieve data from odd-numbered and even-numbered positions
By default, Dispatch retrieves data from odd and even indices.

Components used: ①Line ②Divide Curve ③Dispatch ④Point
As an example this time, we will create multiple point data at the positions where the line is divided and retrieve the odd-numbered and even-numbered point data respectively.

First, prepare coordinate data for 0,0,0 and 1000,0,0.
Next, connect the two sets of coordinate data to the Line(A and B).
Then, a line connecting the positions of the two coordinates was created.

Then connect the line to the Divide Curve(C).
Then, enter the number of line segments into the the line(N).
This time, we are entering the number 10.
Then, as shown in the image above, point data was created at positions where the line is divided by 10.

Next, connect the Divide Curve(P) to the Dispatch(L).
Then, the Dispatch outputs odd-numbered values from the A terminal and even-numbered values from the B terminal.
Since this is point data, we’ve connected Point to terminals A and B.
The image above shows the odd-numbered point data output from Terminal A.

The image above shows the even-numbered point data output from terminal B.
Thus, by default, Dispatch can retrieve data from odd and even indices.
Retrieve data using conditional branching
By inputting True and False data to the Dispatch(P), you can acquire data through conditional branching.

Additional Components: ①Deconstruct ②Smaller Than
As an example this time, let’s try conditional branching at positions where the X-coordinate of the point is less than 500.
Connect the Divide Curve(P) to Deconstruct.
Then, the numerical values of the X-coordinates for each point will be output from the Deconstruct(X).
Next, connect the Deconstruct(X) to the Smaller Than(A).
Additionally, enter the value 500 into the Smaller Than(B).
Then, data with values less than 500 will output True, while values of 500 or greater will output False.
Then, connect the Smaller Than(<) the Dispatch(P).

Then, point data with True and an X-coordinate less than 500 was output from Terminal A.

On the other hand, point data with False and an X-coordinate of 500 or greater was output from terminal B.
In this way, you can implement conditional branching by inputting True and False data to the Dispatch(P).
List of Grasshopper articles using Dispatch component↓




Comment