Tutorial 2 — Grasshopper Intro

Richard Chou
Data Mining the City 2022
8 min readJan 17, 2022

--

If this is your first venture into Grasshopper, it is highly recommended that you go through this amazing Introduction to Grasshopper course by Professor Danil Nagy alongside this class.

As always, let’s start with some concepts…

What is Grasshopper?

Visual Programming

Grasshopper is a visual programming software built on top Rhino. Like any programming language, Grasshopper allows you to build scripts or definitions — sets of instructions and algorithms that instructs the computer to perform certain actions. Traditionally, programming languages are text-based and can often feel intimidating. Grasshopper replaces text-based codes for nodes, components that perform specific operations with clearly defined inputs and outputs. In essence, nodes are clearly defined functions packaged and organized visually to be more accessible.

Thus, the act of writing code is replaced by placing the nodes onto the Grasshopper canvas and connecting wires between the input and outputs to establish relationships. Additionally, since Grasshopper is part of Rhino, it has access to Rhino’s API, meaning that it could access Rhino’s geometry operations and run most of the 3D modeling commands from Rhino that designers are familiar with, making Grasshopper the most popular and versatile design programming language.

Community

One of the best part about Grasshopper is the robust community supported by designers, programmers, and researchers. Often, the best way to learn or troubleshoot Grasshopper is to post a question on the Grasshopper Discussion Forum, where experts and other enthusiasts are more than happy to answer general programming questions or help brainstorm ideas to solve a specific problem. The forum also acts as an archive that allows you to search for similar questions that others have posted.

Plug-ins

Another valuable Grasshopper resource is Food4Rhino, a community-led platform for Rhino/Grasshopper plugins. The open-source code movement where designers to create and share custom tools for public use enhances the Grasshopper’s capability. Some plugins offer general improvements and more sophisticated data tools. Others solve subject-specific tasks that expand Grasshopper beyond only a design tool, and allows the program to run complex analysis and operations ranging from energy performance, robotic fabrication, and urban simulation.

In this course, we will leverage Urbano and Decoding Spaces, spatial-data focused plugins that will help us build complex urban simulation models.

(Left) Grasshopper Discussion Forum | (Right) Food4Rhino Platform

Computational Design

Data-Driven Design

The act of design is largely based on visual cues (with good reason). The same applies to 3D modeling. When working in Rhino, geometry commands allow us to draw — and therefore specifying size and shape — within the workspace freely. Of course, we also have the ability within Rhino to create shapes more accurately, by inputting dimensions in the command bar as we design.

When we design computationally, we rely much more on the parametric control of geometry, not only by being specific with the geometry generation process (no more eyeballing!), but also by placing a much larger emphasis on the spatial relationship between objects (location, orientation, intersection). While Grasshopper still provide lots of “visual cues” in every step, computational modeling requires us to be much more analytical when we design, but also allows more opportunities to inform it with data.

Additive V.S. Associative Modeling

One of the most important concept is to differentiate between the difference between additive vs associative modeling. Typically when we model we start with some base curves representing boundaries of site or building, and creating extruded geometries on top of these base curves. More details are added as we continue to develop the design, hence additive modeling.

The biggest difference between the two, using cooking analogy, is that whereas Additive Design is the act of creating a dish, Associative Design is writing the recipe of the dish. Using computational design, we can employ the computer to create the “dish” that we have designed. Associative design is more flexible because it offers the ability to modify every step within the designing process, meaning that the final result changes dynamically influenced by user input until the moment that the designers is satisfied with the results.

How Computational Design is Applied

  • Design Automation leverages the computer’s ability to repeat the same task multiple times to optimize the design process. When a repetitive design task can be systemized and recreated as a computational model, it becomes a breeze to apply the model not only in multiple instances but also parametrically.
  • Performance-Based design leverages performative analysis to evaluate discreet design and establish a common comparison between different options. There are many performance analysis plugins available to designers via Grasshopper plugins, ranging from structural analysis, thermal analysis, energy modeling, and accessibility analysis.
  • Procedural Design is a method of modeling that builds on top of the two types of computational model methods above. When a parametric model is built to respond to performative factors, in addition to creating actionable insights from evaluations, it can results in having a model adjusting its form in response to the analysis results from previous options (or a base-case scenario).

Grasshopper Components

Components (sometimes called nodes, functions, batteries) are the building blocks of Grasshopper. Components can be classified into three main categories: Input, Container, and Operation.

Input

Input components are built in data containers that allow the user to define specific numeric or logical inputs. Some basic input nodes are:

  • Number Slider (0–10)
  • Boolean Toggle (True, False)
  • Value List (Value 1, Value 2, Value 3…)

Container

Containers components help pass data around in Grasshopper — whether its geometry or parameters. Containers components can only hold specific data types, and there is one container component for each type of data. Generally, containers are separated into to types:

  • Primitive data include all common data types such as Number, Boolean (True/False), and Text that do not directly relate to geometry.
  • Geometric data include any dimensional data-type, meaning that it can be represented inside Rhino’s 3D space. Common types include points, curves, surfaces, Breps (Rhino solids), and meshes. Some of the more uncommon types of geometric data include vectors, planes, and boxes, which are seldom used in visual modeling but in computational modeling.
(Left) Primitive Data Types | (Right) Geometric Data Types
  • Panel is a special type of container because it could

Operation

Operation components are self-contained, task-oriented modules that require accomplish specific tasks. Each operation component require a specific set of inputs, performs a task, and returns a set of expected results. In programming, this is called a function. Functions can look different depending on the programming language, but in generally, they all follow the same Input → Operation → Output logic.

Diagram of a programming function in C

In Grasshopper, functions are presented visually, where inputs are displayed on the left-hand side of a component, and outputs on the right-hand side. Much like a flow chart, users connect respective values into a component, and in turn connects the output into the next operation or container component.

Anatomy of a Definition

A script, or definition, regardless of programming language, is best considered as a series of functions. Much like the individual components, a definition follows the same fundamental programming logic :

Input → Operation → Output

A Grasshopper definition is no different. It allows the user to provide inputs by specifying or referencing values (where geometry or file paths are referenced into the script dynamically). The inputs values are then passed into user-defined operations (typically the bulk of the script).

While not comprehensive, a typical Grasshopper definition usually consist of these parts:

  • Reference — User-defined primitive or geometric inputs (Rhino)
  • Creation — Numeric or Geometry generation (Domain, Surface, Box…)
  • Transformation — Manipulation of data or geometry (Move, Scale, Copy)
  • Analysis — Evaluation or assessment of data (Area, Volume, Point on Crv)
  • Data Management — functions that help with the re-structure of data to ensure operations are performed correctly between different datasets.
  • Visualization — Visualize and stylize output geometry in Rhino Viewport

Due to the spatial and flow-chart nature of visual programming, definitions typically compute from left to right, and top to bottom.

Launching Grasshopper

Interface

  • The Canvas is the main workspace where you build your Grasshopper definition.
  • Tool Box & Menu Bar are located at the top of the window. Here you will find all of the Grasshopper components organized into categories and tabs. Any plug-in that is installed will have its own tab here as well.
  • Display Settings Box is located at the top-right of the window. There are multiple display modes (Shaded, Wireframe, Selective, and Hidden) to control how Grasshopper geometries are displayed globally. You can also adjust display color and quality of the geometry preview here.

Quick Actions

  • The Search Box can be accessed by double-clicking anywhere on the canvas, which allow the user to quickly search for components to place onto the canvas. This is also especially useful when you have an action in mind but is unfamiliar with all the components available — Search away!
  • the Quick Menu can be access by clicking the wheel button or right-clicking anywhere on the canvas.

Getting Started

This tutorial is developed in conjunction with the Module #1 Workshop. Please follow through the workshop exercises to start exploring Grasshopper’s functionality.

--

--

Richard Chou
Data Mining the City 2022

I am passionate about developing data-driven design strategies for urban design and city building of the next century.