How to Use Stream Gate in Grasshopper

Stream Gate in Grasshopper Abstract Icon
Contents

One key tool for managing data flows in Grasshopper is the Stream Gate component. It works like a railway switch that controls whether the input stream will continue to output A or output B.

Instead of manually disconnecting and connecting components to run different sections of your script, the Stream Gate automates this process.

Adding the Stream Gate Component

To begin, let’s add the Stream Gate component to our Grasshopper canvas. You can find it under the ‘Sets‘ component tab, grouped under ‘Tree‘.

Adding the Stream Gate component in Grasshopper from the tabs

To add the component using the component search bar, double-click anywhere on the Grasshopper canvas and type ‘stream gate’, and click on the component.

Adding the Stream Gate component in Grasshopper with the search bar

Inputs and Outputs Explained

The Stream Gate component has two inputs:

Stream Gate inputs and outputs explained
  • the Input Stream (S): This is the data stream that will be directed to one of the outputs. Think of it as our train.
  • the Gate (G) index: This integer defines which output the Input Stream (S) will be directed to, acting as our railroad switch.

The outputs are simply numbered 0 and 1, they represent the two default ‘tracks’ the data can be guided to. What’s special about these outputs is that only one of them can carry data at any time. If the data is guided to output 0, output 1 is empty, and vice-versa.

Basic Stream Gate Setup with Two Options

By default, the Stream Gate component comes with two outputs: 0 and 1. Here’s how you might set it up:

Toggle-Stream-Gate-in-Grasshopper

Connect your data stream to the Input Stream (S) and use a Boolean Toggle for the Gate (G) input. Since Boolean Values (True and False) correspond to 0 and 1, this toggle provides a straightforward way to control which output the data stream should be directed to. If the toggle is set to ‘False‘ (0), the input stream will be output to the output 0 and, if set to ‘True‘ (1) it goes to output 1.

In the image above, you can see the inactive output and its subsequent components are orange, indicating no data is flowing through them.

But we are not limited to just two output stream options!

Expanding to Multiple Output Options

To add more output options, zoom in to the Stream Gate component until you see small plus and minus signs. (If this is the first time zooming up close to the component, you’ll see a popup message explaining how you can add or remove outputs.)

Adding more output options to the Stream Gate component

Click on the plus icon to add as many additional stream outputs as needed.

Since there now are more than two output options, we can no longer use the Boolean Toggle to choose the output. Instead, use a Number Slider, with a range matching our output options. For example, if you have four outputs, set the slider range from 0 to 3.

Example of Stream Gate with multiple outputs

In the example shown above, the Gate input is the number ‘2’, and the Stream (S) input is directed to the ‘2‘ output. All other outputs remain empty.

For detailed instructions on configuring the Number Slider to a specific range, check out my post about the Number Slider.

Happy designing!

Grasshopper Pro

Followed this tutorial? Learn to build the next one yourself.

Grasshopper Pro is a four-module course for architects, built on one method: Design → Logic → Grasshopper. Start with the design intent, turn it into logic, then build it. You'll work on massing studies, façades and patterns, from a blank canvas.

71% of students who finish rate their Grasshopper skills as intermediate or advanced.

See the curriculum →

$197 one-time · lifetime access · 30-day refund

Article by

Picture of Thomas Jeremy Tait
Thomas Jeremy Tait
Founder of Hopific. Expert in parametric design for architecture. An architect who spent 10 years at Snøhetta, where Grasshopper was his main design tool on projects.

Quickstart Guide to Grasshopper

Download your free guide and transform your designs today.

More Great Reads