Ramp Intermediate
Contents
Introduction
Expected Time: 120 min
In this tutorial you will learn how to create a ramp with landings. Landings are parts of the ramp that are flat, so that the user has a moment to rest. There are many ways of building ramps parametrically. This is just one example of creating a ramp along a planar curve. The curve will be the central axis and closely approximates the slope percentage. This definition allows for entering possible constraints defined by Building Codes such as the slope percentage and the maximum length of the ramps before placing a landing.
For this tutorial, it is recommended to have a basic understanding of Data Tree Editing. If you find the tutorial too difficult, take a look at Tutorial 9 - Ramp Easy
The design will be based on several variables:
- The curve;
- The height of the ramp;
- The amount of ramps and landings;
- The length of a landing.
Furthermore, our script will calculate the maximum slope of the ramp. This value can be used to find the perfect base curve for your design.
Base curve, division lengths
In the first step of this tutorial, we create a curve in Rhino. This curve will be shattered in parts for the ramps and the landings, based on some variable number sliders.
Create a curve in Rhino and set it to a curve parameter in Grasshopper.
- Create a flat curve in Rhino
Add three number sliders to the canvas: one for the height of the ramp, one for the amount of ramps and one for the length of the landing. As you probably can imagine, the amount of landings is one less than the amount of ramps.
- Add three Number Sliders for the height, amount of ramps and length of landings
Calculate the amount of landings by subtracting 1 from the amount of ramps number slider. Use a panel as or right-click on the the B input and Set one value.
- Connect the amount of landings Number Slider to the A input of a subtraction
- Set the B value to one using a panel or right-click on the B input and set one value
Let’s find out the length of the base curve by using a Curve length component.
- Calculate the curve length
We now want to know how long the ramp parts of the curve will be. First, multiply the landing length number sider with the result of the subtraction. Now you know the total length of all landings together.
- Multiply the landing length with the result of subtraction
Subtract the landing length from the curve length. We now know the total length of all ramps.
- Subtract the total landing length from the curve length
If you get a negative result, your total landing length is probably higher than the curve length. Try to make the landing length lower, amount of ramps lower, or change the size of the curve in Rhino.
Now we can divide the total ramp length by the amount of ramps, to get the curve length of an individual ramp.
- Divide the total ramp length by the amount of ramps
Since we are planning to shatter the base curve in multiple pieces, we need to have a alternatively list of ramp lengths and landing lengths. Therefore, we repeat the individual ramp length with the amount of ramps, and respectively with the landing lengths.
- Repeat the ramp length with the amount of ramps
- Repeat the landing length with the amount of landings
We now have two lists of ramp lengths and landing lengths.
By weaving the values together, we combine the lists in the correct order.
- Weave the ramp lengths and landing lengths together
Since the pattern input is already set to [0, 1] by default, we do not need to change the pattern.
Unfortunately, we still do not have the data we need to shatter the curve. Use a mass addition to find the partial results of the lengths. You now have a successive list of ramp start values and landing start values.
- Connect the Weave output to a Mass Addition
Shatter the curve
In this step we shatter the curve in ramps and landing. These components will be divided in points, which will be used to move the base curve to the correct height.
First we need to find the parameters of the lengths we found on the base curve. Use an Evaluate Length component to find the Parameters.
- Use an Evaluate Length component using the original curve and the Partial Results as Lengths
- Set the Normalized input to False
Shatter the curve according to the parameters. We now have successive segments of ramps and landings.
- Shatter the curve at the found parameters
Divide the ramp and landing curves into points. Using a higher count input will take your script longer to calculate, but also makes the model more precise. Use a Number Slider to define the count, we will need this value again in a later stage
- Divide the shattered segments
- Use a Number Slider to define the Count
Your model should now look like the following illustration:
Calculate the slope
Since we have defined the total height of the ramp and we found the total length of the curves used by the ramp parts, we can calculate the slope.
Divide the total height of the ramp by the total ramp length.
- Divide the total height by the total length of the ramp parts
Multiply this value by 100 to get the slope in percentage.
- Connect the value to a multiplication node
- Set the B input value to 100
Connect a panel to the Result output. You now have the slope in percentage. If the slope percentage is too high according to your building regulations, change the shape of the curve, increase the amount of landings or make the max height lower.
- Connect a panel to the result
Find the height of the ramp steps
In the “shatter the curve” chapter we have divided the curve ramps and landings into points. Now we will find the correct height of each point. In a later stage, these points will be connected with a line, to get the base for our ramp.
Construct a domain from 0 to the max height of the ramp. We will have to divide this domain in smaller segments, to get the step differences of all points.
- Add a Construct Domain component and connect the height Number Slider to the Domain End
Divide the domain with the amount of ramps.
- Divide the Domain
- Connect the amount of ramps Number Slider to the Count input
The step heights of the ramp parts
In this part, we will calculate the z-coordinates of the points on the ramp segments.
Each segment relates to a single ramp. This segments need to be divided again in the amount of points we divided them with. First you will have to graft the output, so that each segment is calculated individually.
- Graft the Segments output
Divide the domains of the calculated segments with the amount of division points.
- Divide the domain of the segments with the amount of division points
Deconstruct the domain to find the start and end.
- Deconstruct the Segments domains
At first sight, it seems that the ends of the domains are the correct height for each point on the ramps. However, as you can see, one value is missing in the beginning. If we would create a final ramp from these values, the landings would still have a slope, because the last value of the first ramp, and the first value of the second ramp do not match. Therefore we will need to add this value to the lists of points.
Take the first item of the Start output. We now have the first start of the domain of each ramp.
- Use a List Item component to extract the first Start item
Insert the value we found into the list of Ends.
- Connect the Domain End to the List input of an Insert Item component
- Connect the List item output to the Item input
- Set the Indices input to 0 with a panel or internally
Now we have a list of z-coordinates that we can use to move the points on the ramp segments to the correct height.
The step heights of the landing parts
In the previous chapter we have found the z-coordinates of all points of the ramps. Now we need to find the z-coordinates of all points of the landings.
Deconstruct the domains of the overall ramp segments. The End output should give you an amount of values, equal to the amount of ramps.
- Deconstruct the domain of the grafted segments output
Since we do not have a landing after the highest ramp, we do not need the first value. Flatten the End output and cull the last index using the value -1.
- Flatten the End output of the Deconstruct Domain component
- Use a Cull Index component to Cull the End output
- Set the Indices input to -1
Finally graft the output. We now have the heights of all points of the landings.
- Graft the List output
To make the script more clear, connect a number parameter to both List outputs and rename them to "Ramp heights" and "Landing heights".
- Connect two Number Parameters to the List outputs
- Rename the Number Parameters
Find the correct height
Now comes the tricky part of this tutorial. We will need to split the points on the base curve into the ramp and landing part. After that, we move them to the correct height based on the values we found in the last tutorial. Finally we merge the moved points together again.
Simplify the Points output of the Division points.
- Simplify the division points output
Simplifying reduces the branches of a data tree. For example {0;0;0} becomes {0}. This can help you to make two different lists interact with each other in the correct order. Generally speaking, we try to avoid simplifying, because we lose information about the origin of data.
Let’s extract al the tree paths that belong to the ramps and landings. An easy method is to use the Tree statistics component.
- Find the branches of paths of the Points output
Now we will dispatch the Paths output. Since the Dispatch pattern is already True-False, we can leave the input empty. By connecting a panel to the List A and List B output, you can see that List A contains all the ramp branches and List B contains all the landing branches.
- Dispatch the paths output
Use two Tree Branch components to extract the points that belong to the found branches.
- Extract the points with two Tree Branch components
In your viewport you can see that by selecting one of the Tree Branch nodes, only the points of a ramp/landing type are selected.
Move the ramp points
When you connect a panel to the points of the ramps we found and a panel to the heights of the points of the previous chapter, you will see that the numbers of the branches do not match. You can solve this by using a Match Tree component and use the points as guide.
- Add a Match Tree component to the canvas and connect the ramp Tree Branch output to the Guide input
- Connect the ramp heights to the Tree input
Create a Z-unit vector from the heights.
- Connect a Z-unit vector heights from the Match Tree component
Move the ramp points to the correct height.
- Move the ramp points with a move component
In your viewport you will see that all the ramp points are moved to the correct location.
Move the landing points
Moving the landing points works exactly the same as the ramp points. However, since the first and last point of the ramp are already implemented by the ramps, we will need to cull them. You will need to simplify the output.
- Connect the landing Tree Branch output to a Cull Index List input
- Set the Indices input to 0 and -1
- Simplify the output
Match the height values data tree using the landing points data tree as guide.
- Add a Match Tree component to the canvas and connect the landing Cull Index output to the Guide input
- Connect the landing heights to the Tree input
Convert the height values to a z-unit vector.
- Connect a Z-unit vector heights from the Match Tree component
Move the points using the z-unit vector.
- Move the landing points with a move component
In your viewport you will see that all landing points have been moved to the correct height.
Finally merge the moved ramp points and moved landing points into one data tree.
- Merge the moved ramp and landing points
Create the ramp
In this chapter we convert the points to a real ramp. First create a polyline from the points.
- Flatten the Result output
- Create a polyline from the merged points
We need to find the curvature at each point on the polyline. Therefore, we will need its parameter. Use a Curve Closest Point component to find the parameter of the points.
- Connect the Result output to a Point input of a Curve Closest Point component
- Connect the Polyline output to the Curve input
Evaluate the curve at the found parameters to get the Points and Tangents.
- Evaluate the Curve at the found Parameters
In the right image, you can see the Tangent vectors of each point.
We now need the vector perpendicular to this Tangent vector. Use the cross product to find the perpendicular vector. You will need to connect a Z-unit vector to the Vector B input.
- Calculate the Cross product of the Tangent output
- Connect a Z-Unit Vector to the Vector B input
The cross product is a mathematical calculation to find the perpendicular vector to vector A and B.
In the right image, you can see the perpendicular vectors to the Tangent vectors in the XY plane.
From the cross product vector, create two SDL lines from the original points. For one of the two SDL-lines, use a negative component, to alternate the direction.
- Create two SDL lines from the Point output using the Cross Product Vector as direction
- Connect a Negative node to one of the Length inputs
- Connect a Number Slider to the Length input and the Negative input
Your viewport should now look similar to the following image. By changing the length of the SDL-lines, you can change the width of the ramp.
Join the SDL-lines in positive and negative direction.
- Join the SDL lines
Loft the joined curves.
- Loft the joined curves
You now have the base surface of your ramp.
Thickness of the ramp
You may want to give a thickness to the ramp. Extrude the surface in the negative z-direction to give your ramp a thickness.
- Extrude the surface
- Connect a Negative component to the Direction input
- Create a Z-Unit vector to the Negative input
- Define the thickness with a Number Slider
Your model is now finished!
If the base curves has sharp corners, the loft result may not function. Try to bake the joined SDL lines and remove some of the lines in the corners. After that you can loft them in Rhino and extrude them to give the ramp a thickness.