Visual programming 2
Introduction to Grasshopper
Last updated
Introduction to Grasshopper
Last updated
Components are organized semantically into palettes. The application contains a few hundreds of components supporting basic operations such as number arithmetic to exotic geometric functions such as Voronoi diagrams and meta-ball blobs.
We cannot possibly cover but a fraction of the most common and useful components relevant to building foundations in computational design. Additional palettes visible above, but not in your computer, are component libraries available online.
Input sources for components may be constant values, geometries linked from the CAD document, files loaded from the disk or more commonly other components’ outputs. Generic primitive input components are found in the “parameters” palette.
There are multiple and often equivalent ways to create simple constant values. For text strings, the “panel” component is typically used. It captures the convenience of a plain text editor, where we can input arbitrary string fragments. To activate the editor we need to double-click on the component. Notice that depending of the zoom level the editor may appear in-place or in a new window.
For numeric values we often use the “slider” component. Certain components such as the “slider” contain special customization options accessible by either double clicking or using the context menu and selecting the appropriate item. The slider component options allow us to define whether the number output is an integer or a real, as well as the upper and lower limits of the slider’s range.
Most components accept values via their “set” context menu option. For constants it is common to assign values that will never change using this approach. The benefit of using the “set value” context menu option, is in that it does not clutter the graph with components. As a good principle we may rename a component holding a constant value as seen below, for legibility purposes.
The most common source of input parameters comes from selecting already drawn shapes in the CAD document. To import geometries we use geometric primitive components and select objects from the viewports using the context menu “set one” item.
It is also very common to import more than one geometric entities using the same approach. Instead of the “set one” context menu, we need to use the “set multiple” menu. The geometry, one or many, is stored in the geometric primitive component as “referenced” data. This means that changes of the geometry in the CAD document will cause all components that “reference” it in the visual programming environment to be updated automatically.
Some geometric primitives, such as points, are so basic and useful that we can create them directly via the input parameters. Note that geometry created from this type of primitives is not stored in the CAD document but only within the visual programming environment.
In this example we create a point by first selecting the “set one” option, then in the command line we select by “coordinate” to express the desire to draw a new point instead of selecting an existing one, and then add one point in the viewport using the mouse. Notice that points created using the approach can be moved by using their on screen handles. The handle appear only when the point primitive component is selected in the visual programming window.
Primitive parameters, either geometric or non-geometric, when first created have no value assigned. This is represented by the orange colour tint and popup menu item notification. Connecting such “undefined” values to other components propagates the warning forward. This is also visually represented by an orange colour wire.