1st March 2024

GHEC 05 : Build Your First Grasshopper Model

The Model

We want to build a line truss model that looks something like :

Pasted image 20240124101625.png

and of course, since it's Grasshopper, we will build this parametrically, letting us re-configure the truss based on some inputs.

Build the Top and Bottom Chord

I'll start by building the top and bottom chords of the truss. I will be building everything in the xz-plane, so use the front view in Rhino.

Pasted image 20240124101927.png

I'll make a line with a point and a vector to create the bottom chord in Grasshopper.

Note: Double-click on "front" to maximize the viewport in Rhino

Then, I'll move the line in the z-axis by some distance to make the top chord. This distance is also the height of our truss.

Add the Vertical Webs

So far so good. Now, we can work on adding in the vertical webs of the truss. They are just vertical lines between the top and bottom chords.

Pasted image 20240124102922.png

To build the webs, I'll divide the chords and then connect the points. But before that, I am going to use containers to label our chord lines. I do this so that I know the context of the geometry I am working with.

Note: Hold ALT and drag any component to make a duplicate of it

If you noticed, I am using the curve container but you can use a line container too. Now, to divide the curves and connect the points.

Add the Diagonal Webs

Now, we get to the final and trickiest part of the model, the diagonal webs. It's tricky because we are going to be working with patterns which will put into practice everything we have learnt so far.

Just to to tidy things up, I am going to again create containers for the geometry and move them elsewhere.

To start making the diagonal webs, we need to first identify the points to connect. We want every second point on one chord and to skip every second point for the other.

Pasted image 20240124104914.png

To do that, we can actually treat these points as a pattern. One that alternates between True and False. If we can somehow tell Grasshopper that we want the True points and not the False, we can make our diagonal webs.

Pasted image 20240124105536.png

To apply this pattern, we can use the dispatch component that comes with an alternating True/False pattern by default.

Note: You can hover over the P input and see the pattern.

Dispatch will return the True points in output A and the False points in output B. Then, all that's left is to join the True values of the bottom chord with the False values of the top chord.

If you then use a line component like we did before, you will notice that we only get "half" a web. This is because the line only takes in two points and it will only join the True point with a False point. We need a solution that will draw a curve that joints all the points.

Polyline and Weave

We can get that with a polyline component, which takes in a list of points and draws a polyline through all of them. The question now is, how do we sort and group all our points into a single list?

We want our list of points to follow an order like this:

Pasted image 20240207092831.png

The most straightforward way to do this is to use the weave component. Which as its name implies, "weaves" together data. Remember the pattern from before? All I am doing here is reconstructing the list based on the same pattern.

It takes in two lists and merges them into a single list depending on a pattern.

Rhino_uZ1gzlIFlC.png

Similar to the dispatch component, the weave components come with a default pattern of alternating 0 and 1 which means it will put the item from List 0 and List 1 in an alternating sequence.

This is perfect, because we want to put the points of our top and bottom chords in alternating sequences too.

And with that, we have our line truss model. But, we are not done. There is something special about the dispatch component that we should look at.

Changing the diagonal web pattern

If you have noticed, the visuals of the trusses in this lesson aren't consistent. That is because there are actually two ways of making the diagonal webs.

When we use the dispatch component, we actually have two choices. We can choose the True points of the top chord and the False point of the bottom chord. Or, we can choose the False points of the top chord and the True point of the bottom chord.

Thus, we can make this an input so that anyone can change the pattern based on what they like more.

To do this, we need to make both options in Grasshopper and use a toggle and a filter component to control what geometry to preview.

What that means, is Grasshopper will compute both options but I am using the filter component to control which option gets previewed.

It's important to know that Grasshopper is still computing both options. It's technically doubling the work that Grasshopper has to do but since joining points is a lightweight operation, we can get away with it. But do be careful of heavier operations in the future.

Overall Model

With that last step completed, you have modelled a parametric truss in Grasshopper! Not only can you play around with the height and width of the truss, you can even change the truss options too.

You can take this a step further and modify the pattern for any kind of truss shape.

Pasted image 20240124114432.png

Don't worry if you got lost in any of the steps, I have linked the script to today's session at the bottom.

Today's Homework

Having made this model together, it's time for you to do a bit of exploring and modelling on your own. So, for today's homework, there are two things I want you to do.

  • Use other curves for the chords
  • Turn the 2D Truss into a 3D Truss

Task 1: Using other Curves

Use what you know to modify the script so that it takes other curves for the chords instead of a line. Try to use what you learnt in the last session about referencing, and use drawn curves from Rhino.

For inspiration, this is what my truss looks like after modifying the script.

Pasted image 20240124114944.png

Task 2: Turning the 2D Truss into a 3D Truss

Try turning the truss that we made into a 3D model. You can use what we already have, move it and then connect the lines. Or, you can try your hand at using data-trees. It's up to you! But I do recommend trying the data-trees , it's a good way to get some more experience with trees.

Again for inspiration, here is what my 3D truss looks like.

Pasted image 20240124115112.png

Final Thoughts

This truss is a good example of how most Grasshopper scripts are created. You have straightforward parts, like creating the top and bottom chords. But you also have to solve more complex problems like creating the diagonal webs of the truss.

To be able to come up with novel algorithms takes experience and creativity. So, spending time and solving a diverse range of problems is key to mastering Grasshopper.

Resources

    -->