Grasshopper Ramp

From TOI-Pedia



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.

The variables are:

  • Total Height
  • Slope Percentage
  • Maximum Length Slope
  • Length of the Landing
  • Width Ramp

Calculate Required Length

Add txt
Add txt

First, we'll do some mathematics to determine the required length of the total ramp. In this specific example we'll use 4500mm (b), but this can be set as a variable. By dividing the total height over the slope percentage (5%), you determine the total length of the ramp in plan: 90000mmm (a). For this we use Maths » Operators » Division.


To find the projected length for the ramp in plan, we use Pythagoras. Multiply the Maximum Length Slope of 20000mm (c) with the Slope Percentage with Maths » Operators » Multiplication. This gives you the height per ramp (b). Then use Maths » Polynomials » Square. Do the same for the the Maximum Length Slope. Subtract these from one another with Maths » Operators » Subtraction Lastly, take the square root with Maths » Polynomials » Square. Now, you have the projected length for the ramp (b), we will use this to divide the curve.

Let's see how many of these 20000mm ramps fit in the total ramp of 90000mm. Using Maths » Operators » Division, divide the total length of the ramp by the number you've just calculated. Use the floor of the Maths » Util » Round to obtain the number of ramps. This is 4 in the example. Since this leaves us with 10000mm, we need to take into account that the last portion of the ramp will not be the same size. However, it needs to maintain the same slope! This is what makes this definition a bit tricky at times...

Weave and Repeat

Add txt
Add txt

In this step we will create a list that alternatively lists the length of the ramps and the length of the landings. For this we have to define the Landing lenght with a Number Slider. For the example we use 1400mm.

With Sets » Sequence » Repeat Data we generate two lists. One repeats the data for the length of the ramps by the number of ramps we have just retrieved with the Round component. The other one repeats the data for the number of landings. Since we know we have to add one more short ramp at the end, the number of landings is the same as the number of ramps, also 4 in the example.

Next we will weave these two lists with Sets » List » Weave to alternate between the two numbers. With Maths » Operators » Mass Addition we will generate a mass addition. Now we have obtained a list of the lengths to be placed along the curve in the following step.

Before we do this, we have to insert the additional last ramp. Multiply the length of each ramp with the number of ramps and subtract this from the total length of the ramp. Add this to the last item of the mass addition. This gives us the left-over ramp still needed to complete the required total length. Now we have to add this number to the list.

Use Sets » List » Insert Items. Use the Partial results from the Mass Addition component as your list. Retrieve the length of the list from the Mass Addition as the insertion index. And the Item to insert is the Result of the addition. Check your list to see if it has the correct order.

Define Input Curve and Test against Required Length

Add txt

Define a planar input curve. Make sure it is drawn at the correct scale. We will build a test to ensure that the input curve is equal or larger than the required length. If this is not the case, you first have to draw a longer curve before you continue.

Set the Rhino-curve in Grasshopper and determine it's length with Curve » Analysis » Length. Use Maths » Operators » Smaller Than to perform the test. Use the total required length of 90000mm to test against. With Sets » Tree » Stream Filter we can control the outcome of the test. In this case, if the test fails, the 0 input will be used. If the test is true, the 1 input will be used. If we leave the 1 input empty, the definition will crash, you will notice this by all the components turning orange and red.

The output of the Stream Filter will be the same as the defined input, a curve in this case. Now we will place the ramp lengths on the curve with Curve » Analysis » Evaluate Length. Retrieve the lengths from the Insert Items list and plug them in the Length. Set the default Normalized option to False or right-click and select Invert instead.

Shatter and Separate Curves

Add txt
Add txt
Add txt

Next we will shatter the curve with Curve » Division » Shatter. Enter the parameter t from the evaluate length into the parameter input on shatter. Check the length of each curve with Curve » Analysis » Length. You'll see that the precision is slightly off. This has to due with the tolerance settings of Rhino/Grasshopper.

We'd like to separate the 20000mm ramp-curves from the landings and the shorter ramp-curve because they will be treated differently for the remainder of the definition. To do so, we could test which curves are equal to 20000mm. But due to this tolerance issue Grasshopper won't recognize any of these curves as 20000mm long.

Instead we use a domain, where we add/subtract 10mm from the Maximum Length Slope variable and test which curves are included within this domain. Use Maths » Domain » Construct Domain and Maths » Domain » Includes. Plug in the Maximum Length Slope Number Slider into the A and B input on the Construct Domain component. Use an expression x-10 for A and another expression x+10 for B. Then enter the Length into the Values input on the Include Domain component and add the contructed domain into the Domain input. Use Sets » Sequence » Cull Pattern to extract the curves who are included in the domain.

To obtain the short ramp we know that the length needs NOT be 1400mm (since those are the landings) but smaller than 20000mm (otherwise it would have been a full ramp). Construct two domains for this. The first one starts from 0 for A to the variable Number Slider Landing Length. Add an expression x-10 for B. The second domain uses the Landing Length again, this time as input with a expression x+10 for A and for B we use the Maximum Length Slope Number Slider with an expression x-10. Then we use Maths » Domain » Includes again to test whether one of the curves has falls within this domain. To apply both domains to the test, we have to use Maths » Operators » Gate OR. This means if the lenght falls in either domain A or B, it passes the test. Now you have 4 ramps of 20000mm and 1 shorter ramp, separated.

Generating Slope and Landings

The next step involves dividing the curves and moving those points to the correct heights, using the Maximum Slope Length and the Slope Percentage. Again, we treat the 20000mm ramps separately from the shorter ramp, we will move this one later.

Moving the Ramp Points

Add txt
Add txt
Add txt

First, use Curve » Division » Divide. Use a Number Slider or Panel to define a number. For more accuracy, use a higher number, such as 1000. For simplification and explanation, we will use 10 and later increase it to 1000. We need to determine how much the points should move vertically. To calculate this, multiply the Maximum Slope Length with Slope Percentage and then divide it by the number of division points, currently set at 10.

When you divide a curve by 10 segments, you obtain 11 points. Therefore we need to create a series with 11 items. Use the Addition component to add 1 to your 10 division points and use this as input for the Count of the Sets » Sequence » Series.

Now the tricky part. The first and last point of each of these 20000mm curve segments need to be at the same height, because of the flat landings in between the ramps. If not, you could have used a series for the next steps. Instead, we are going to repeat this list, separate them in groups of 11 and then add the starting height for each platform afterwards. To do this, find the length of the list with the 20000mm curves by using Sets » List » Length List. As mentioned several times, this is 4. Multiply this with the Number of Points, 11. Feed this into the Repeat Data component as Length of the list. For the Data you plug the series. The result 4 times the same series.

Let's make groups of 11 items by partitioning the list. Use Sets » List » Partition List and insert the Data from the Repeat Data component and use the Number of Points, 11 as partitioner. You now have a grafted tree with 11 items per branch, each with the values of the original series, starting at 0.

If we now calculate the height at each of the landings, we can add this to the list. For this, we make another series, starting at 0 with a stepsize (N) that we've already calculated, the Maximum Slope multiplied by the Slope Percentage. The Count is 4 again, coming from the length of the list of curves. Right-click the Series output and select Graft. This is important to match the data structure of the partitioned list. Add the two together to get the correct heights. Now the last number in a given branch matches item 0 of the next branch.

Move the points from the curve division with the calculated heights. Convert the list of numbers into a vertical direction with the Vector » Vector » Unit Z. With Transform » Euclidean » Move you complete the operation.

Moving the Short Ramp Points

Add txt

It's time to concentrate on the short ramp. We can divide the curve by the same number of divsions, despite it's shorter length. However, the stepsize changes in this case. Obtain the length of the curve and divide this with the Slope Percentage. Now you have the vertical stepsize per point. Use a series to create a list for every point. For the Count we again have to add 1 to the Number of Division Points, becoming 11.

Since the shorter ramp will always be the last segment, we need to move these points upward from the highest point of the last regular ramp. You can get this number by Sets » Tree » Flatten Tree and the Sets » List » List Length. Write an expression x-1 and use this as Index for the Sets » List » List Item. Add this number to the series and use a vertical vector direction to move the points, similarly to the step described above.

Drawing and Ordering Ramp Curves

Add txt

Draw an interpolate curve through both sets of points with Curve » Spline » Interpolate Curve To merge the two sets, we need to ensure that the shorter curve actually gets inserted at the end of the set of curves. For this we use Sets » List » Insert Items. Retrieve the length of the list with Sets » List » List Length. The ramp curves are the List you want to insert into. The Item to insert is the short ramp curve. The insertion Index is the List Length. Now all ramp-curves are in the same list in the correct order.

Finalizing Ramp

Add txt
Add txt
Add txt

Lastly, we give the ramp a width variable so that we can generate a walkable surface. Use Curve » Division » Horizontal Frames to place a horizontal frames along the curve. The Number of frames doesn't matter so much, so you can leave the default set to 10.

On these horizontal frames, we will draw a perpendicular SDL line using the y-axis of the planes, in both directions and then we will loft through these. This ensures that the previously drawn curve on which the slope percentage is calculated is located in the middle. To do this, specify a width with a Number Slider. Divide this in half to determine the length of your SDL lines. Draw two SDL lines with Curve » Primitive » Line SDL. To extract the origin and y-direction of the plane use Vector » Plane » Deconstruct Plane. As the Starting point, plug in the Origin and the Y for the Direction. Invert one of the the lengths or directions by using a Maths » Operators » Negative component.

Now, merge the two SDL lines with Sets » Tree » Merge and then Curve » Util » Join to join them together. Afterward, you loft them by using Surace » Freeform » Loft

To make the landings, we simply use the surface we have just generated. Extract the surface edges with Surface » Analysis » Edges and then select the edges where the landing is to be located, in this case 1 and 3. Use Sets » List » List Item for this.

Now we have to remove the 1st edge from the first surface and the last edge from the last surface, because those do not require a landing. Let's use Sets » List » Shift List for this. Right-click on the Wrap input and select Invert. For List Item 3 you Set a Number of 1. For List Item 1 you Set a Number of -1. Make sure the List Items are flattened, because otherwise the shift won't work.

Flip one of the curves by using Curve » Util » Flip Curve and then merge them with Sets » Tree » Merge. Be sure to simplify and graft them here, so that they are coupled correctly when using Surace » Freeform » Loft again.

Combine the ramps and platforms one more with Sets » Tree » Merge. The file also has some additional self-explanatory calculations displayed in panels to show some statistical information such as the total length of the final ramp.

Personal tools