Rhino Grasshopper: Stair Generating Tutorial (Part 1)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello in today's grasshopper tutorial we will be learning how to make an algorithm that creates stairs between a top curve a bottom curve and with any given number of steps these curves can also be manipulated which is what makes the design parametric and which what is what makes this software so powerful all right so how do we begin well let me just disable this function that i've just created and we'll start from correct scratch i already have my top curve and my bottom curve and i'll just leave those but we need to import them into grasshopper using the curve container we can just right click and set one curve and in this way we can bring the top curve and this bottom curve into grasshopper we need to update this bottom curve by resetting one curve and set this bottom curve great now we have these two curves defined in grasshopper so we can hide our rhino version and that is all we need from rhino so we can get our viewport all situated and let's begin working grasshopper so the main node that we're going to be using is tween curves and this will give us our construction curves for the stairs as you can see i can plug in a factor between zero and one and each number will represent a curve somewhere between these two original curves now something to note if i turn my curves on in rhino and i flip one of these these curves have directionality and it affects how this tween curves operates so after flipping one of the curves you can see um the tween curve has to flip around before moving from one curve to the other so you should make sure that your curves are aligned in the correct direction by just typing out flip in rhino or you could also flip a curve in grasshopper anyway to get all of the um lines construction lines to create the stairs we're going to need to give this input a range of factors each factor corresponding to a step so how does this range node work by default it takes in um a domain from zero to one and so it creates a list of numbers that range from zero to one and by default does 10 steps which means it has 11 values a step is a gap between two numbers so there's always one more values created than there are steps good to remember all right so now that we have our construction curves we can preview everything else off but we want to have a little more control of this range if we plug in for instance 12 steps you'll see that affects the number of stairs we create great so now that we have our construction lines all we have to do is extrude them up and then loft them together we're extruding them to create the vertical portion of the stairs and then lofting them to create the horizontal portion so to create the vertical portion we're going to extrude in the z direction how far do we want to extrude well there's an equation for that to find the height of each stair you take the um total height of stairs and you divide it by the number of stairs so i typed slash slash and that's a easy way of getting a panel that says anything you want it to um anyway to find the the total height of the stairs what we're gonna have to do is take the height of the top curve and subtract away the height of the bottom curve how do we find the height of the top curve well we need to find its z coordinate so we'll use a point on that line let's use point on curve to find just any point on this line you can see how we can um adjust where this point is but it doesn't matter because wherever i move this point to it's going to have the same z coordinate the same height so if i deconstruct this point which i've just extracted from the top curve now i can tell that the z component is 23. if i do the same by copying and pasting this and plugging it into the bottom curve you can see that z component is negative eight so all we're gonna have to do is subtract the height of the bottom curve from the height of the top curve and we'll have the total height as you can see our result is 31. and that is the height of our staircase now we just need to divide the height of the staircase by the number of stairs which we already have set here let's label it let's call this number of stairs great it's always good to be clear in your code so that when you go back later you can quickly understand what you were doing previously so now that we have calculated the height of each stair we can plug that in to the extrusion distance and to verify that this is exactly the correct height we can flip views maybe view it from the front and you see that it aligns per each stair aligns perfectly with the one directly above it perfect okay and then after you do something new it's always good to check and make sure everything still adjusts exactly as you would expect and in this case it does okay let's loft these curves together to create the flat sections how are how are we going to do that well we're going to want to loft this curve to that curve this curve to this curve and so on all the way up this list so first let's extract those curves from these surfaces so if i use the command deconstruct prep then i will have extracted for each input surface a list of edges right um n equals four means that there's four items in each of these lists of edges which makes sense because each of these surfaces has four distinct edges so if i take the first edge from every group by using this list item node what is this list item doing is taking in a bunch of lists see each of these is a list with four items and by default it's returning the zeroth item or the first item the index is like a coordinate system for knowing the position of an item in a list so by default we're taking the first item in each of these lists and as you can see these edges are lighting up for every surface what if we take the second item at index one great we've just found one of the edges that we want to loft together i could copy and paste this and try and find the other um and just through intuition i think it's going to be at 3. great we've got all the curves that we need to lofts together um i think that there's a better way of doing this though because each list only has four items in it this list item has this handy feature where you can just add some pluses and now if i plug in a curve to each of these outputs you can see that this has the second item in every list and this has the fourth item in every list great now we're going to need to loft these together um but things are gonna get a little bit complicated here what does the loft command do specifically um i will show you in rhino by creating some curves so if you loft a list of curves together it doesn't matter how many there are you they will be connected in order that they were given to create a surface just like that um so what we're going to want to do is enter in a bunch of groupings each containing two curves that we want lofted together otherwise this loft node is not going to know which two curves we want lofted together so how do we set up that grouping system well um first let's do a little maintenance on our lists you can see in this list we have an extra curve down here we don't want that we're not going to be lofting this curve anywhere so we can delete it how do we do that we use coal index and we can delete let's try the last item in the list because we know it's at one end of the staircase i mean this is the first item in the list excuse me um and you'll notice whoops we've accidentally deleted everything that's because these items retained their groupings so we only have one item in each list so deleting the first item in each list is deleting everything we need to flatten this to break down the groupings so that we're only deleting the first item in this one long list now let's see what we've got oops we didn't we still haven't deleted it so now we know that it is the last item in the list so let's highlight these items here and yes we have deleted the correct item from this list retained all of the others so now that we know that that was the last item in in that list we know that to lead to delete this very top edge which also isn't going to be lofted anywhere we can just delete the first item in this other list and again we're going to have to flatten our input and that can be done there or here or just about anywhere and now we have these lists where the corresponding items for instance the first item in this list we want to lofts to the first item in this list and that's perfect because if we now throw these items into their own groups graft is how we're going to do that now each item is going to have a grouping around it we can do that for both of these lists and so the three numbers before each group are like the title of the group there are some extra zeros in there so if we simplify it we can just see a simpler version of the title of every group and you can see here it's a similar indexing system to that of individual items but it's used for groups the first group is zero the second group is one the third group is two um and that's pretty straightforward and the reason why this data structure is helpful is that let's display our data actually if we have groups that have the same header those are technically the same group and what that means is that we can feed all of these curves into one container and now each of these groups will have one item from each of the lists that it that's feeding into it and so now our loft command knows exactly what needs to be lofted together so if we just loft these curves together we could do it like this okay um it didn't work and why is that well i'll show you another little trick about loft um so first let's put down some curves so if i want to loft these together and i'd choose the same end of each of the curves so ends that line up then we're going to get a surface however if i choose opposite ends so these curves are not facing the same direction we're going to get this weird distortion type thing so all we have to do because we're one of these curves is clearly flipped is just flip all of the curves in one of these lists then plug it back in oh no um we need to press shift to plug it in but now we have too many curves in each group so we can undo this wire by pressing control great so now we have defined our function let's just test it um great everything seems to be working but it's a little bit messy i have all of this uh code i don't necessarily need to access it all i can delete my panels but how can i consolidate this code here into just one function like i had up here well that's actually quite simple um if you select everything that performs just one task just like this i'm being very uncareful right now um just for demonstration um i i'll get a cluster that takes in the inputs that it had um and outputs to any wire that was connected to that cluster of of um nodes so if i explode this cluster i get back what i had only a little bit stretched out it's a slight bug here okay but how do we tailor this cluster to look exactly how we want it to well first of all it had all those unnecessary inputs because we haven't consolidated our inputs so if i place down some curves and it's not going to work for a second so bear with me because there's no cr there are no curves set here about to right click and reset these curves um then i've consolidated all of these wires into nodes that only take one input and that is key i'll have to do the same thing for the number of stairs by using a number container and let's just label this number container a little more descriptively number of stairs great and so now we only have three wires feeding into the cluster that we're going to be creating and one wire feeding out actually that's not true this is our output we have no wires feeding out let's attach abrep to the output a prep is a category that contains surfaces and poly surfaces in case you're wondering um we can preview everything off except our final brep output and good thing we did because i'm now realizing we forgot to include our vertical extrusions to our output great so now we've consolidated our outputs and let's put them all through one wire now if we perform the cluster again making sure that there's only three wires feeding in only one wire coming out and making sure that all of the input nodes are correctly labeled if we cluster it you'll notice we have this convenient little function now that has a top curve a bottom curve and a number of stairs and for the rest of your design career you will easily be able to make stairs between two curves by implementing this function another cool thing is that once you've made it and labeled it stairs between curves then you can look it up stick stairs oh my goodness yes here it is stairs between curves great um where is it plugged into it's already plugged in uh it it's plugged in all the way up here because the default node the one we just looked up was already plugged in so it actually retains its input if the original version still has inputs so we don't want that to happen so you'll notice this is the one that uses capitalization um so that's the only that we've just changed stairs because we have a bunch of these stairs between curves clusters now that we can look up but we'll use the capitalized one and it has no inputs fantastic um it's all ready to go and that is all about making algorithms in grasshopper thank you
Info
Channel: Grasshopper 4 Rhino - Tutorial Central
Views: 2,488
Rating: 5 out of 5
Keywords:
Id: qgVKY-P-Owc
Channel Id: undefined
Length: 20min 0sec (1200 seconds)
Published: Thu Feb 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.