Grasshopper: Visual Scripting for Rhinoceros 3D. David Bachman

Читать онлайн книгу.

Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman


Скачать книгу
this is just one way in which a user can interact with a script. For example, one can use a Control Knob (Params tab, Input panel) in place of a slider to simulate setting a dial. However, this is really just an alternate way to do the same thing.

      The number slider itself is an extremely versatile component. As we have seen, some components expect a real number input, such as the R input (radius) of the Circle component. Others expect a natural number as an input, such as the N input of the Range component. Sliders can be used at those inputs, too, by right-clicking on them and changing the “Slider type” to “Integer.” For example, examine the simple script depicted in Figure 3.1. The output of the slider determines the number of real numbers that the Range component will pick in the given domain. These numbers are then passed to the X input of a Construct Point component.

img

      Another useful way to interact with a Grasshopper script is with the Graph Mapper component (Params tab, Input panel). Examine the script depicted in Figure 3.2. This script creates 10 circles at different heights, parallel to the XY-plane, and lofts them. The radius of each circle is determined by a function depicted right on the Graph Mapper component. When you right-click on this component, you’ll have the choice of a variety of different types of functions under the “Graph types” submenu. Each such function is marked with a few white dots that determine its shape. Moving these dots around changes the function, and therefore the final output geometry. One can see the effect of this in Figure 3.3.

img img

      For a different way to interact with Grasshopper, try building the script depicted in Figure 3.4. The Series components (Set tab, Sequence panel) in this script are each outputting the list of numbers 0,1,2,...,9. These are both fed into a Construct Point component, with the second one grafted, thereby creating a 10-by-10 grid of points. The Point component toward the bottom of the script is referencing the highlighted point in the Rhino viewport, defined by right-clicking on the component and selecting “Set one Point.” Both the grid of points and this individual point are fed into a Distance component (Vec tab, Point panel), which measures the distance between the chosen point and each point of the grid. Finally, these distances are used as the radii of circles, centered at each grid point.

img

      To reveal the interactive nature of this script, make sure the Point component is selected, and move the referenced point around in the Rhino Top viewport. You’ll notice the pattern of circles changes dramatically as you move it. See Figure 3.5. In a similar way, any Rhino geometry can be used as the basis for an interactive Grasshopper script. Creating a curve in Rhino, and referencing that curve by right-clicking on the C input of a Pipe component, creates a surface. Modifying the curve in Rhino (by turning “Points on,” for example) will cause Grasshopper to modify the resulting surface.

img

       Curves and Surfaces

      Grasshopper has a lot of specialty components for working with curves. Many of these require that you understand curve parameters. A curve parameter is a number that corresponds to a specific place along a curve. The set of all numbers that correspond to curve points is called the domain of the curve. You can easily see the domain of a given curve by hooking it up to a Domain component (Params tab, Primitive panel), as in Figure 4.1.

img

      Once you have determined a curve parameter (i.e. a point in its domain), you can use it with several other Grasshopper components. Consider, for example, the script depicted in Figure 4.2. Here we have fed the output of a Curve component to the D input (Domain) of a Range component to pick out 10 different curve parameters. These are then, in turn, given to a Curve Frame component (Curve tab, Analysis panel) to define a series of planes that are tangent to the given curve at 10 different places. Finally, we use a Circle component to define 10 circles in these planes.

img

      Notice the circles in Figure 4.2 are not equally spaced along the curve, even though the Range component defined 10 equally spaced values of the curve parameter. This is because the transformation from curve parameter domain to a three-dimensional curve is not uniform speed. Where this transformation is faster, the circles are farther apart. If evenly spaced circles are more desirable, one can choose curve parameters with the Divide Curve component (Curve tab, Division panel) instead of the Range component, as in Figure 4.3.

img

      Grasshopper includes many shortcuts that circumvent the direct interaction with curve parameters. For example, if you want to make circles perpendicular to a curve, rather than tangent, you can replace the Curve Frame component


Скачать книгу