# Railing

## Introduction

LEVEL: BEGINNER
Expected Time: 20 min
Possible result of this tutorial

One of the advantages using parametric design, is that you can do repetitive tasks very easily. One example of such a task is the design of a railing. First, let’s think about the parameters that are important for our railing:

• The shape of the railing
• The amount of bars
• The height of the handrail

## Creating the Railing

Create a curve in Rhino and set it to a curve parameter in Grasshopper

The creation of the shape can be done in several ways. In our case we do it on the basis of a curve created in Rhino. Let’s start creating a curve and add it to a curve parameter in Grasshopper.

Divide the curve in a pre-defined amount of points

Now we want to divide the curve into separate parts. Generally speaking, there are three ways to do that:

• Divide Curve: divides the curve in a specified amount of points;
• Divide Distance: divides the curve in a preset distance between points.
• Divide Length: divides the curve in segments with a specified length

If we look back at the parameters we defined, we see that we want to be able to change the amount of bars and not specify it by any length. Therefore we add a Divide Curve node. This node asks for a curve which is the parameter we made before, and a count. For now, you can leave the Kinks input as it is.

• Divide the base curve Curve » Division » Divide Curve

Add vertical lines to from the points on the curve

Next we will create a line from the points we just made. Lines can be generated by several functions, but in our case, we are looking for a SDL line. SDL stands for Start, Distance and Length.

• Create vertical lines from the points Curve » Primitive » Line SDL

In our case we want the railing to go upwards, so let’s add a Z-unit vector as well.

• Specify the direction with a Unit Z vector Vector » Vector » Unit Z

Finally you can add a number slider to specify the height.

• Add a Number Slider to define the height Params » Input » Number Slider

Move the handrail up with a move function, with the same height of the bars

We now have the bars but we also want to create the handrail itself, by moving the original curve in the z-direction with the same distance as the line length.

• Add a move component to the canvas Transform » Euclidian » Move
• Connect the Z-Unit vector to the motion input of the move node.
• Connect the Length number slider to the Z-Unit vector.

As you see, the move-function created a copy of the original curve we drew, but now moved it up.

Give the curve a thickness by creating a pipe

Now we have all the components needed for the railing. By adding a pipe function to both the move node and the SDL Line, you will see all the lines get a thickness.

• Place a Surface » Freeform » Pipe on the canvas.
• Connect the SDL Line output to the curve input of the pipe.
• Connect the Geometry output of the move function to the curve input of the pipe.
• Connect a Params » Input » Number Slider to the radius input of the pipe.

Of course it is also possible to make different pipes for the bars and the handrail itself. Just add an extra pipe function and connect it to the move geometry. This option is visible in the final script image.

Finally we can change the Caps of the pipes, by right-clicking on the Caps inputs. In our case, we choose for the flat Cap. By connecting a number slider, you can alter the Radius of the pipes.

• Cap the pipe railing RMB caps input of pipe » Flat

Add a parameter and set the preview off of functions that are not important for the final result.

For good practice, add a geometry parameter and, if you want, rename it to "Final railing". By selecting all nodes before the final parameter and setting the preview off, you will only see the final result in your Rhino viewport.

• Select multiple nodes by Hold LMB » Draw rectangle over nodes
• Set preview off RMB on canvas » Preview off

Final script with two pipes. One for the handrail and one for the bars.

## Rectangular challenge

LEVEL: INTERMEDIATE
Expected Time: 30 min

After you created a pipe based railing, you might want to create a railing with rectangular bars. This is a bit more difficult because you need to define the direction of the rectangular section of each bar individually. In such cases, it is useful to create a so-called Plane on each point. After that, you need to create a rectangle on each plane and extrude it in the z-direction. The following image will show you one method how to do this. Feel free to challenge yourself and try to make your railing script more advanced! If you are not able to complete this script at this moment in the TOI-pedia tutorials, that is completely understandable. Come back at a later stage when you finished the beginner tutorials.

An example script for a handrail with rectangular bars and a rectangular handrail. Challenge yourself!