S206E057 – Spring 2016 S206E057 -- Lecture 12, 5/20/2016, Interaction between Grasshopper & Rhino Copyright ©2016, Chiu-Shui Chan. All Rights Reserved. Tutorial introduction: 13 online series of exercises @ http://vimeopro.com/rhino/grasshopper-getting-started-by-david-rutten. 1. Basics of interface between Rhino and GH – lecture 1: http://www.grasshopper3d.com/page/tutorials-1: Getting started with Grasshopper (GH) on GH canvas and create a GH definition. This video explains the connection between GH and Rhino. GH is a plug-in which components have geometry. These geometries will be displayed on Rhino, but they can’t be selected or changed. We could build up connections between Rhino geometry and GH geometry. GH geometry must use a mechanism (for instance, a point) to provide point input for GH geometries. Otherwise, the GH components shown on Rhino are just previews. This is the notion of interface between Rhino & GH. Generating previews uses a lot of processing power, so disabling preview of components is recommended. a. b. c. d. 2. Define a line in GH by click Curve menu > Select Line and put a line definition in GH. Right click A > “Set one point” to put a point in Rhino as the starting point of the line Right click B > “Set one point” to put an end point in Rhino. This GH line in Rhino and the line component in GH are both in green color. But, the line in Rhino can’t be selected nor moved. Now build up a line that works both in Rhino and GH: i. Draw two points A and B in Rhino. ii. Right click A in GH > Set one point > In command line, select point type in Rhino> change the Type from Coordinate to Point and select a point. iii. Then, the Rhino point geometry will serve as the input of the starting point of the GH line component. iv. Repeat the same procedure for point B, the drawn line could be edited by moving the pts in Rhino. v. If the input Type is coordinate, then the coordinate of points, no the geometry, will be imported to GH. Creation of 3D curves – lecture 2, Multiple Components—Generate changing lines between curves. a. b. “Draw” two curves in Rhino, “divide” the two curves to 20 Rhino pts. Set up “line” component in GH, and use “Set Multiple Points” to reference points on Rhino line A to GH A; and points on line B to B. Then 20 lines between pts are drawn. If GH component is closed, then the lines will disappear. Use Bake to save lines to Rhino. To make an algorithm to divide and connect points is the following. c. Draw two curves in Rhino. d. Set up two divide curve GH components, Curve panel > Division. e. Use “Set One Curve” with each component on “C” input part to connect the GH with the Rhino curves. f. Define a “line” component; link both output P of “Divide” to the input A&B of Ln. Lines are drawn. Page 1 (5/21/2016) S206E057 – Spring 2016 g. h. Apply Params > Primitive > Integer component with Integer value set up and link it to the count input. Apply Number slider with the range of 0<10<100 as input with Integer defined and link to the count to make the change dynamic. In this case, 10 was the default number. We shall link the Number slider to Integer Primitive to declare that the input is integer type for the count (N). In results, we will have two Rhino curves, and flexible GH points, If we move the control points of these Rhino curves up in Z direction, then they could be seen as two arches, The linked GH lines could be treated as beams connecting these two arches in space. All we need are columns, trusses, or cables to support these arches and beams. The image on the lower left has zero linked line, whereas the right one has 100 links. These elements on the right image have GH points and lines with no surfaces yet. We have to put meshes to make them solid and bake into Rhino model component. 3. The method of editing the GH component in real time – lecture 3, refining a definition: a. Apply the same two curves done in Tut-2. b. Add a new curve in the middle of the two curves. c. Set up a “divide curve” definition in GH. Assign it to the middle curve. d. Define a “number slider”, and a “pull point” to project points from an object to the nearest objects (Vector > Point > Pull Point). Select G in the pull point component, right click > select “Set One Geometry”, select curve A. Connect point output in Divide Curve component to the point input in “Pull Point” component. e. Then, make a copy of the Pull Point and assign its geometry to curve B. (Note: The divide curve is to divide the curve by the number of segments. The other component that divide the curve by length is the function of Curve panel > Division > “Divide Length”.) f. Use an “Arc-3pt” definition or a line definition connecting the divided three curves, see the following results. Here are the different results from applying different algorithms. The point is to use simple algorithm for good results. 1. Method 1: Applying the first algorithm used in the last exercise with the control points of the two curves being lifted up with various Z values to get 3D effects, the connections between two curves are straight lines. Page 2 (5/21/2016) S206E057 – Spring 2016 2. Method 2: Applying a curve in the middle of the two curves, which is drawn with the same amount of control points as the other two curves, lift up the Z value of the middle curve smoothly. Then apply 3 point curve function to get the edges curvedly connected. The Pull Point function in GH will not be able to get a constant cut along the top of the curves to get a good result of arch supports. See the picture next page. 3. Apply divide function to three curves and define a 3 point arc. In result, the final form is a smooth series of arches, lined up along the evenly divided distance from the curves. After the arcs are generated, select the arc component, and right click to select “bake” to bake the geometry to Rhino as parts of the Rhino model. Note: Baked geometry is a copy of the GH geometry. Any alterations in GH will result in alterations of the GH geometry not of the baked geometry. 4. Creating Biarcs: Note: A biarc is a kind of model commonly used in geometric modeling and computer graphics. It is composed of two consecutive circular arcs with an identical tangent at the connecting point. Since the tangents at the connecting node are the same, the G1 continuity property is preserved. G1 means that the curves share a common tangent direction at the join point. a. b. c. d. Draw two curves in Rhino. Define two “Divide” components and assign both to the drawn two curves respectively. Create a slider with “0<5<50”, which creates a slider with minimum of 0, maximum of 50 and default is 5. Then, link the slider output to the input N of two “Divides”. These two curves are divided into 5 segments with 6 dividing points. e. Generate a biarc component, Curve panel > Primitive > Biarc, link the output P of Divide A to the Start point of BiArc, and the other point of Divide B to End point of Biarc. Page 3 (5/21/2016) S206E057 – Spring 2016 In this example, we could apply Vector > Vector > Unit Z to create a vertical curve by defining it as the Ts input. This means that the vector Z is parallel to the world coordinate Z axis. g. For the end point tangent of Te, apply another similar Z component vector to it. f. h. The curves are down and we need to reverse the vector to make a smooth curve. Vector > Vector > Reverse. Link the Z unit output vector to Reverse input and Reverse output to the Biarc endpoint tangent. i. Page 4 (5/21/2016) Results of the single curve are the combination of two curves, which could be changed by ratio. Ratio could be the slider between 0 and 1. 0 ratio will have the curve meets at the end of one curve. 0.5 is the default of meeting two curves in the middle of the resulting curve. S206E057 – Spring 2016 j. These two parts of the resulting curves could be lofted to form 3D meshes, Surface > Freeform > Loft, by linking A1 to Loft A, and A2 to Loft B. Two meshes will be created. See the image on the lower left. k. Then, join the lofted two meshes into one. Note: a mesh is a boundary representation, which is recognized by the Brep component. Brep Join is a function to join a number of boundaries or Breps together, Surface > Utility > Brep Join. l. Hold down shift to link the two Loft outputs to the “Brep Join” input. At this point, the generated surface is a polysurface. Can the united mesh, the polysurface, be extruded to generate a plate? m. In GH, Surface Offset only works on individual surfaces. It cannot handle polysurfaces. At present GH doesn’t have a solid offset component even though Rhino 5 has a command for this now. If the polysurface is not a complicated one, one could bake the Join Brep to Rhino, and apply OffsetSrf to make a solid out of it. But, results of this example are too complicated for Rhino to handle. Summary: The benefit of creating geometry directly in GH is basically that it is defined by parameters and therefore easy to change. Sometimes you don’t want to change a certain shape, then it is better to create it in Rhino and import it. 5. Example of utilizing BREP to create a vase There is a component called Brep that needs to explain. Brep is a collection of faces, or Boundary REPresentations. The face could consist of an underlaying surface (which may be a Nurbs surface, or a revolution surface, or a sum surface, or a plane) including trimming curves. Thus, a Brep consist of faces, surfaces, loops, trims, edges and vertices. It is in fact a topological entity much more than a geometric entity. See the following example of utilizing BREP (Params > Geometry > Brep) to simulate the generation of creating a glass vase with a special module attached. Here are the short explanations of the algorithm. Page 5 (5/21/2016) S206E057 – Spring 2016 1. A surface will be created or say summed up (Sumsrf, Surface > Freeform > Sum Surface) by combining two curves. In this example, one is the profile of the vase and the other one represents its height. The resulting surface, which is the overall volume S, shall be divided (Maths > Domain > Divide Domain Square or Divide Domain2) into grids by X (U) and Y (V) number. 2. The basic module of the form pattern (lower right image of a cross plate) will be imported from Rhino into GH through Brep, and it will be used to morph on the Sumsrf. Thus, we need a Bounding Box to orient the geometry. (BBox, Surface > Primitive > Boundary Box, or type bbox). 3. The bounding box shall be deconstructed into its own constituent parts (DeBox, Surface > Analysis > Deconstruct Box) to get its x, y, and z values. 4. Results of the DeBox will provide the z value to represent the height (or say the depth of the body of the vase) and the overall volume S of SumSrf are used to create a twist box on a surface patch (SBox) and deformed (Morph) by combing the module (Geometry), the BBox (Reference box) and SBox (Target) together into the final object. The concept of morph is to transform or be transformed completely in appearance or character. Here are the curves. Here is the GH program that creates a composition. Here is the image of a compositional module. Here are the results. 6. Another example of creating an organic form a. Create three curves. b. Move curves to the right positions, see the image on the right. c. Put a Curve component in GH, click set multiple curves and select the three curves sequentially by Reference Mode. In this case, the sequence of selection matters a lot. d. Set a Loft component and link the curve output to C input of Loft component. e. Apply divide domain square component, it will allow us to divide the domain by U and V dimensions. Page 6 (5/21/2016) S206E057 – Spring 2016 f. Generate two number sliders of 0<20<40 for U & V on domain component. This is the idea to divide a domain into equal segments. See lower left image. g. In Transform > Morph > Surface Box, or type Surface Box and link the output of Loft to Surface input of SBox, the D input is the divide output. The height could be defined by number slider of 1. See upper right image. h. Model a basic pattern by box, sphere, and Boolean Difference. See lower left image. i. Apply Brep > select the Brep of the modeled pattern. j. Transform > Morph > Box Morph, or just type Morph in the component search window. The box morph component will morph an object into a twisted box. In this case, the G of Morph is Brep output. The Brep could also serve as the reference box (R input) for the Morph. See upper right image. k. Create a more advanced pattern of double layers of the pattern, see lower two images. Page 7 (5/21/2016) S206E057 – Spring 2016 l. Redefine the Brep by clear value and set multiple Brep again to select the double layer. m. Use a Bounding Box (Surface tag > Primitive > Bounding Box) to group the geometry together into a box representation. Its Box output is the reference of the Morph component input. The Brep geometry is the geometry input G of Morph. See the results of applying the first pattern below. n. For the second pattern, rotate the pattern 180 degrees, to get the result as the right image below. Reminder: As mentioned, we constructed the generation of the geometry step by step. That means that when we start using GH we will often first analyze on how to build the required geometry. What steps do we have to make. That was why it was mentioned in the beginning of the class as backward thinking that thinks back to your Rhino modeling algorithms for implementing them in the GH. Keep in mind that many functions in Rhino like drawing a curve are supported by manual input of the mouse, or by changing the settings of that curve function in the command line. In GH we don't have that option. We will have to define every step of the process of generating geometry with the help of the modules. Drawing a line is not selecting the curve function and then click with the mouse to define the curve, instead it is a process of defining the points of the curve and then generate a curve from those point. This will take some additional effort, however it allows us to define the points in such a way that we can easy alter them afterwards, in this case with the help of number sliders. Page 8 (5/21/2016)