From the course: Learning Algorithmic Design with Grasshopper

Offsetting Voronoi cells

From the course: Learning Algorithmic Design with Grasshopper

Start my 1-month free trial

Offsetting Voronoi cells

- [Instructor] Over the last few videos, we've spent some time setting up the first stages of our Grasshopper definition. We've finished up making a 2D Voronoi pattern, and we've started building out some of the inputs for our shelf parameters. Now, in this video, I'd like to move on to some of the further steps. So here I'd like to focus on this next step of drawing trapezoidal panel profiles. So there's actually a lot to this step, so we'll break it down, probably into several videos. But the first step towards tackling this is to take each of the cell profiles and to offset it to the interior. So let's move this other one out of the way, the draw spine profiles, we'll tackle that later. And what I like to start with in Grasshopper is a geometry component and that'll let us feed in the Voronoi cell pattern either coming out of the dynamic cell pattern or the static cell pattern, so we can just connect those very easily and let it flow to the rest of the definition. One step I want to make sure that I take here is on this geometry input, I'm going to right click and I'll graft this input. So basically, when we're putting in multiple cells, each cell will get its own data path and that'll become important as we go through the rest of the steps in our algorithm. So from there, let's look at tackling that offset. So we can bring in an offset component, so offset curve is what we want. And so that component takes as its inputs, a curve to offset, a distance, a plane, and a corner type. And the default is just none, but we could set this to sharp or round or smooth or chamfered. So the first thing I'll plug in here is the output of that geometry component, and plug it into the curve component. And I can see there in my Rhino window, I now have an offset. Now for the distance, I'd like to make myself a slider. Since I'm working in centimeters here, I'm going to give this an offset, starting from zero, going up to, let's say 3.00 centimeters. So I'll give myself a couple of decimal places there to do a little bit of precision, and I can plug that in, and dial it up or down. Now, one thing I'm noticing is that, as I change that number, my offset is happening on the outside of that cell profile, and that's not what I want. I want this to actually go towards the inside. So I just need to invert that distance number that's coming out of the slider. So I'll do that with an expression. And we'll just have one input here so I'm going to zoom in, remove that parameter, double click to edit and I'll just say, X times negative one, hit okay. So that'll just take that output from the slider and invert it. Let me plug that into the distance, so now I can see, as I increase that distance, we're now offsetting towards the interior. Now, I could do an expression just by right clicking and typing in an expression here, on this offset component. I like to actually use the expression component, because then I can visually see, what is the expression that's being applied to this number? While I'm at it here, I'm going to right click on my slider, and this will be shelf thickness. So since this is one of my input parameters, I'm going to drag this all the way down to the group I created earlier, right click and just say, add to group. While I'm over here, I'm going to grab this plane and plug it into the plane input. And again, that just gives me the option of switching from the XY construction plane to a different plane if I felt like it later on, okay? So now I'm able to offset each of the cells I put in, and I can switch from the static cell pattern where I'm specifying one single cell out of the list, or I can plug in that dynamic cell pattern, which contains the whole thing and I can see all of those are getting offset so that's great, Grasshopper's taking a lot of the grunt work out of it for us. In the next video, I'd like to take a look at adding a couple intermediary steps here before I do the offset, and that would let me add some space in between each of these cells and that'll help out later on as we add things like dimensions so things don't get so crunched together, and it's just easier to see and understand.

Contents