Grasshopper Tutorial Beginner (Easy)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this grasshopper tutorial i'm going to summarize the basics of the program this is a great and easy tutorial for grasshopper beginners and can serve as a crash course into parametric design for grasshopper i'll cover the basic grasshopper interface how to create parametric relationships simple patterns animations data trees how to install plugins and just general workflow tips so what is grasshopper grasshopper is an algorithmic plugin for rhino and grasshopper gives us parametric control over a series of relationships that we're able to define through a node-based interface it could be considered as a method of visual coding and it's a great way to gain great greater control over your design in rhino with grasshopper we can in theory create infinite design options through a series of relationships we design and control in grasshopper let's take a first look at the grasshopper interface if you're opening grasshopper for the first time there's kind of two ways you could get the interface up the first would be to click on this little launch grasshopper icon under the standard tab in rhino and the second would be to simply type in grasshopper into the command line and you'll get a little loading screen and then your grass up a window will appear i'm just going to go and create a new document so i've got a blank kind of document and my first tip for you is when you're using grasshopper don't go full screen with grasshopper you want to use it in conjunction with rhino so try and dock it so you've got like a half screen half rhino screen and you can use those two things in tandem so the general interface is pretty simple you've got your typical file menu at the top then we've got a bunch of tabs with things called components and i'll talk about components shortly but they're basically the building blocks of grasshopper and then below that we've got this big gray open space called the grass upper canvas navigating the grass up the canvas is pretty easy you can scroll in and out with your mouse to zoom in and out and then you can hold the right hand mouse button down and pan to move around the canvas quickly as i mentioned before the building blocks of grasshopper are basically these things called components and components actually kind of relate to the things that we typically do in rhino for example if i were to create a sphere in rhino i would type in sphere into the command line and i'd get a bunch of options that specify how i'd go about creating the sphere i could click and then define a radius for my sphere i could do that manually give it like a radius of 20 hit return and create a sphere grass up is quite similar but we get a lot more control over some of these parameters in the sphere interactively so let's go ahead and try and create a sphere inside of grasshopper using a grasshopper component to create a sphere let's navigate to the surface tab and go to the primitive drop down menu under that we had a few options for spheres i'm just going to go with the typical sphere option here and i click once you'll see my cursor has changed to have a little plus sign and this is prompting me to drop my first component onto the grasshopper canvas so i'm just going to click here onto the grass upper camera so i might zoom in a little bit just to get started and you'll see two things have happened we've got a little battery-like object on our grasshopper campus which is our first component and then over here in our rhino window we've got a little red previewed sphere that's occurring and these things are related if i click on the sphere you'll notice it turns green and that tells me that that's this kind of previewed geometry that we've selected in grasshopper what i mean by previewed is right now i can't actually select this geometry in rhino it's purely a preview i can't touch it i can't move it basically all of my transformations will be have to be happening inside of grasshopper as we move forward with this there is a much easier way for us to kind of find objects in grasshopper so obviously when we want to do something in rhino usually we just have a guess if i want to create a box i type in box and i get a lot of you know options for box creation basically and we can do a similar thing in grasshopper so i'm just going to delete this guy if i double click on the canvas and i type in sphere i'll be able to find the sphere component right there and just click and that will create it then so once again you double click on the canvas with your left hand mouse button and just type in whatever you want so if you wanted to create a box you could also type in box and create that as well we're going to keep going with our sphere to begin with though so most grasshopper components have some kind of combination of things called inputs and outputs so these little kind of nodes that you see in our sphere and these inputs and outputs kind of give us control over the properties of our object in the case of the sphere we have two inputs and one output and to understand what these are we can just hover over those the names of those inputs and outputs so one of the inputs is the base plane which basically specifies the location and the orientation of our sphere and you can see it previewed as this little grid here that's our base plane for the sphere the r input is the radius which is currently set to one so by default our sphere has a base plane of just the world x y that you see generally in rhino and a radius of one and what it outputs is a untrimmed surface so the resulting sphere actually comes out as a surface geometry so we can actually affect the properties of this sphere by parametrically changing these inputs and outputs the easiest way to test this is to first create something called a number slider and we're going to create a number slider that allows us to change the sphere radius the easiest way to create a number slider is to double click on the canvas and don't search for number slider just type in the value that you want for your sphere radius so i'm going to go with a value of 5 and what i'll do is create this slider with a value of 5 but it has a domain of 0 to 10 and i can easily slide it across to change its value i'm going to leave it at 5 for now and then i'm going to update this radius of the sphere to be the same as this number slider so to do that with my left mouse button i'm going to hold coming out of the slider and i'll get a little arrow i'm going to drag that in and it's going to snap into the radius of my sphere so i'm going to snap and let go and you'll see that my sphere size has changed as a preview in the rhino viewport and that's because i've increased the radius and this can change dynamically so as i slide this number slider along i can dynamically change the radius of our sphere so there's a few other types of inputs that we could use in grasshopper to affect things like this i could create something called a panel and panels are really fantastic tools for using as inputs but also using to see what you've got as an output so for example i could make my panel dot by double clicking on it change it to a value of 7 and plug that into radius and that'll make my sphere a size of 7 units but then i could also plug the s output into the panel and it will just tell me that i have a surface coming out of this sphere component so i have one surface and this is really useful when you've got multiple objects coming out of your component because then you can clearly see what's actually coming out of the outputs so we've created a number slider and this is of the type number and there's like a series of different uh data types as we would call them inside a grasshopper so as i hover over this radius output you'll see this little 0.1 icon next to the radius and that indicates that the sphere wants to take in a number input the b input the base wants to take in a plane input so you can see that based on the little icon as well and a few of the different data types that you'll be using in grasshopper can kind of be found in their primitive section up here under geometry so we could create points and this will give us a point container but it also shares the same icon as a point we could create curves we can create planes as we know and points can actually serve as inputs for planes often they can be interchangeable geometry types as we know we could create surfaces we can create meshes and quite importantly we can create something called a brep now a brep can be thought of as a poly surface which you would be familiar with if you're a rhino user so just think of a brep as a poly surface surfaces and breps can also be used interchangeably as well so if i plug this sphere into here it'll light up green without any issues as well so that's just an overview of a few of the different data types that you'll come across in grasshopper i'm going to keep my point container because i'm going to quickly talk about how these simple geometry containers here that only have one input and one output can actually be used to reference geometry inside of rhino so if i were to go and create a point in rhino by just typing in point and just dropping a point onto the canvas i can actually create a relationship between my grasshopper canvas and this point so i'm going to come over to my point container i'm going to right click and i am going to set one point i'm then asked to kind of select an object to reference so i'm going to just do a marquee over that point there and you'll see that this point kind of turns like has a little bit of a red cross on it so now if i move the point in rhino you'll see that it its location updates in the grass upper preview so the grass upper preview of this point is now tethered to the point physically in rhino and now we can go ahead and create a parametric relationship so a parametric relationship is basically a relationship between two objects that we define in grasshopper now grasshopper typically reads left to right so objects to the left of our definition can affect objects further downstream to the right of our definition and i'll show this in action right now so this point geometry i mentioned before that points can serve as planes or locations and we're going to basically create a parametric relationship between this point and sphere so i'm going to plug this point into the b input of sphere and you see it snaps on nicely and what that will do is it'll update the location of this sphere to be located at wherever this point is so what that means if i move this point in rhino you'll notice that the sphere will update as well and we can kind of easily move that around and see that relationship in place let's say we're happy with this fear now and we want to bring it into rhino so we can make it part of our design obviously it's a preview and grass up and we can't currently select it but we can actually move it into rhino through a process called baking to bake a geometry just right click on the icon of your component and you'll find a little bake option that comes up i'm going to select that click ok on the panel that comes up and you'll see you get a baked sphere that represents this sphere that we had in grasshopper and it has no relationship to the parametric relationships with built up in grasshopper anymore it's just a dumb geometry inside of rhino we can also bake components by clicking on the component itself and right clicking somewhere on the canvas and selecting bake and we could also bake multiple components so if i selected the point and the sphere i could bake those guys out as well and i would end up with two spheres that you'll see two points in that same point location that you see here grasshopper has some really great ways for us to control what we can and can't see in the rhino preview you probably already noticed that when i click on a grass upper component it turns green and the corresponding geometry turns green in rhino so if i click on my point that also turns green but we can actually manage this a little bit when we have much more geometry coming onto our canvas for example if i created a scale component and we scaled from the center point of this point here we're going to scale this sphere and maybe we scale it by a factor of 2. you'll see i have a new sphere that's created as an output geometry from the scale component and what we're starting to get is a little bit of an overlap with our geometry of our point our initial spear and then our scaled sphere what if i just want to preview this last sphere only there's a couple of ways that we can go about doing this the easiest way is to just select all the components that sit behind this scale and right click on the canvas and select the preview off option they'll turn a darker shade of gray you'll notice the difference in shades here and that means that they're off inside the grasshopper window so that means that we just see this scale option here another way to preview components selectively is to come up here and do the draw preview geometry for selected objects only so if i click on that everything is going to disappear unless i click on one of these components so regardless of whether or not your component is previewed on or off you will be able to see what it looks like with this option selected here so i can then click on these objects and clearly see which one or which geometry i've selected that's really helpful if you're trawling through a definition trying to kind of understand what's going on or what something's hap what a certain component is doing i'm going to click that back off to go back to our normal mode we could also turn this one on which is the wireframe preview see the wireframe of our sphere and then if we click on this one it will turn the preview off altogether i'm going to go back to just our standard which is the draw shaded preview geometry and nothing else another helpful performance tip that's worth noting is that we can disable components inside of a grasshopper so if i want to make this sphere not actually compute at all i could click on it and right click and click on enabled and that will disable this component entirely it'll turn a dark shade to gray and nothing's basically happening now i could right click and re-enable it to get it back if i disable this middle sphere it means that the geometry coming into the scale component no longer exists so i no longer have an input for that scale component so just be aware that when you're disabling and enabling geometries or components in grasshopper if you have parametric relationships build up those relationships will be affected by the disabling and enabling in your definition one last little tip that i have around grasshopper performance is the grasshopper profiler now this is a really fantastic tool that shows you the speed of the components and how they're computing if you've got a really slow computing definition and you want to figure out what's causing the slowness this is a really cool tool to have to turn it on go to display and under canvas widgets there's a little option called profiler i'm just going to click that on i'm going to create what's called a populate 2d component and that creates a random population of 2d points basically and then i'm going to plug that into a mesh sphere component so messview is a little bit different to a sphere it creates a base type or data type of a mesh and i'm going to plug that into the base and we're going to create a whole range of mesh spheres we're not super interested in that right now what we are interested in this is this little kind of 7ms icon that's appeared below the grass upper component this is telling us the speed that this component is computing at so when we kind of compute 100 mess spheres at each of these points it computes at you know this speed so if you have something that's computing really really slowly and grass up it'll actually turn red and you better isolate which component is causing you a bit of grief now that we've got a better understanding of the basics let's try and design something in grasshopper being an algorithmic tool grass up is really useful for designing amazing patterns one commonly used tool by beginners in grasshopper is the varonoi pattern a voronoi pattern is a way of defining regions based on a collection of points and they usually produce cellular patterns commonly seen in nature so grasshopper comes with a voronoi component to help us create these patterns easily if we just navigate up to the mesh tab and go to the triangulation drop down menu you'll find a collection of voronoi components and options i'm going to select the simple voronoi component click and drop it onto the canvas so you'll notice nothing's actually happening right now and we get a little error on our varano component telling us the input parameter points failed to collect data let's have a look at the inputs we have for the varno component we have a collection of points that will form the virado diagram we have radii as an optional cell radius we have a boundary that we can contain our diagram within and then we have an optional plane for the voronoi diagram to sit on so the easiest way to get started with the voronoi diagram is to create a collection of points rather than clicking a collection of random points in rhino and then referencing them in we can really easily create a random collection of points using grasshopper if we navigate to the vector tab and go to the grid drop down menu you'll see a few populate options i'm going to select populate 2d and what this will do is create a collection of points within a boundary inside of grasshopper so you'll see if i click on it i have all these points specified in grasshopper and there's they're caught within this boundary of this rectangle here so the populate 2d component basically randomly generates points within this boundary so the region is defined by a rectangle which we see is that region that everything sits within the count gives us the number of points to add which is currently a hundred so if we increase that we'd have more if we decrease it we have less the seed is quite interesting this is how grasshopper generates randomness if we change that value from one to say two we'll get a different type of randomness basically and then you can also add to a pre-existing point population so we're not really going to worry too much about the inputs right now we're going to go straight ahead and use our point list we've generated and plug it straight into the voronoi component so we can get our first voronoi diagram and you'll see straight away this cellular-like pattern appears around our points and basically the way the voronoi works is it measures the distance between neighboring points find the midpoint and find the perpendicular line between those points and then just basically create a cell around each of those neighboring points in their perpendicular line so you'll notice i have a bit of an issue with my populate 2d right now the boundary extends really far out way further than the actual specified boundary we have in our populate2d so what we're going to do is we're actually going to add a region which will be a rectangle that will also act as the boundary for vary and i'm going to do that by creating a rectangle in grasshopper so i'm going to come up to here into the geometry container and create a rectangle you can obviously double click and type rectangle on the canvas as well and i'm going to right click on my rectangle container and set one rectangle and you'll see in the top left i get a prompt just as if you were drawing a rectangle inside of rhino so i've got to specify the first corner of my rectangle i'm going to specify it then i'm just going to make my rectangle a length of 50 by 50 units and i'm going to hit return and you'll see my kind of previewed rectangle comes here is this square we've created i can go ahead and drop that into our populate 2d component and it will immediately update and those 100 random points that we've generated will fit within this rectangle that was specified now i also want to contain the voronoi diagram within this boundary as well so i can drag that into the boundary input for the voronoi and you'll see it just cuts off that extra outside bit and we get a nice simple cellular pattern for our varynoid diagram we could then go and add some more control over this so i could go and change the count for the populate 2d from 100 to maybe say 150 150 and that will give me a denser diagram so you see we're adding points to this population and then that affects the varonoi pattern because it has more points as an input so i could drag this slider up and watch my voronoi diagram update i could also make it less dense and much lower resolution as i drag that right down to say like 10. so you can have a really quick play around with that kind of parametric relationship another really kind of helpful thing to note about this simple voronoi component i'm just going to quickly create a new one to show this is that we could turn this into kind of like a facade pattern or something for a building or some kind of you know construction project that you're working on with a different type of relationship so this boundary that we actually have here whilst it takes in a rectangle input it can actually swap out to be a surface input so if we create a simple surface inside of rhino say with like you know a plane so this will just create like a nice simple two 2d flat plane for me which is a surface in rhino you can see there and if i reference that surface in here i'm going to go right click set one surface like that so you'll see that this surface is now tethered to my rhino surface it's referenced into grasshopper like how we've referenced the points earlier we could go and actually populate some points on top of this surface so if we jump over to the vector tab again and go to grid there's a populate geometry component and this works very similar to the populate to do but it takes any kind of surface or volumetric geometry and basically puts points on top of that surface so if i go and plug my surface into geometry you'll see a bunch of points appear on the surface and now as i move it around they kind of follow that surface so we can then go ahead and drop the population into points and we get our voronoi diagram and then this surface can also act as a boundary for our voronoi pattern to cut it off and this gives us a lot of control because now we can you know rotate this surface with our gumball and the varno pattern will actually follow along with the surface at any kind of rotation that we put it on which is a really great way to you know translate something in you know a 2d surface into maybe a more three dimensional form and this works in the exact same way as the populate 2d component i could make a number slider for 150 increase the count and i once again get that parametric relationship that we had before so we could easily now go and turn this into a 3d voronoi diagram if we navigate to mesh and go to triangulation you'll see there's a component called voronoi 3d i'm going to click on that and drop it onto the canvas now the voronoi 3d component has less inputs it's asking for a collection of points and then it's asking for an optional boundary or a box in this case so the points for the voronoi diagram that we could create if we go back to our vector tab and go to grid this time we could select the populate 3d component and this doesn't just populate a geometry or a 2d plane but rather a box specified us or by us or a region it's going to put those points within so i'm going to drop that onto the canvas now you'll see the region's asking for a defined box i'm actually going to go and create a box component just a simple geometry container you can find it under params geometry i'm going to right click on the box and go set one box starting from 0 again i'm just going to do the same size as this rectangle so i'm going to go 50 50 and then 50 up in the z axis like that and this will form as our region so i'm going to plug my box into there and you'll see i now have populated the inside of my box with you know 100 of these points so i can go and put those points into the voronoi 3d diagram we can just make sure that it's capped within our boundary by putting the box in as the region and now if we kind of preview off a few of these components that we have on our canvas you'll see i get a 3d voronoi pattern with 3d objects and if i were to go and bake that you know i get all these kind of interesting cellular pieces of geometry attractives in grasshopper could essentially be thought of as relationships between objects that affect one or more other objects based on their distance between it's a really great way to create simple and elegant patterns let's create a simple voronoi attractor algorithm using a point in rhino where the voronoi cells will become smaller the closer they are to a point let's begin again by setting up a vorono relationship so we dropped a rectangular component on the canvas last time and said set one rectangle i'm going to go with 50 and 50 again as my size i'll just delete that surface i am then going to create a voronoi component just the standard virun i here and i'm going to create a populate 2d component i'm going to plug the region into the populate 2d and the boundary of the aronoy and then the varying will have be taking the points of the populate 2d so in rhino i'm going to create a point which is going to serve as our attractor point and i'm going to place it somewhere in the midst of our rno diagram just there for now in grasshopper i'm going to create a point container and i'm going to reference in our point from rhino so i'm going to set one point and select that point there so as i mentioned an attractor works based on distance so let's measure the distance between this point and the center cells of each vary cell that we've got so i'm going to use a component called distance and this is a really great component just for measuring the distance between points so point a is going to be this collection this list of points we've created here and point b is just going to be our point so what that will do if we create a panel is to create a series of number values that's basically a list telling me how far this point is to this point this point to that point this point to that point on and on for 100 of those points but what's interesting that we can leverage is the algorithmic knowledge here is that the points really close to the attractor point are all going to have really small values and the points much further away are going to have really large values so what we can do is we can leverage these values and create a relationship that could scale or change the size of these voronoi cells so i am going to use a scale component so this one here with the two circles we've used it once before and the geometry that i'm going to scale is these voronoi cells so i'm going to plug those cells in we're plugging in 100 cells by default the scale component wants to scale from you know a center of over here so you see it's just scaling the whole thing down based on this point but we can use our center of scaling as this list of populate 2d points because item 1 in our list of cells is related to item one in the list of populations so this point is related to the same cell in these two lists so i'm going to plug my population into the center and you'll see it straight away scales down every single cell from its center point now what we can then do is change the scaling factor right now we've got an overall scaling factor of half 0.5 but we can use this distance to kind of leverage a new type of scale if i plug that in right now the scale is going to be too big you get this kind of big mess of geometry and we don't want that so i'm going to press ctrl z what we want to do is we want to mathematically adjust these numbers so i'm going to use a component called multiplication which just this one here and we're going to multiply all of these distance numbers by a really really small value i'm going to go with 0.01 as my number and that'll just give me you know a really small value to multiply by we can kind of see now you know the original distances were like 34 30 sometimes you know much higher than that sometimes much lower and the new values are much smaller than that so they're you know down within this kind of factor that we've already got on our scale so if i go and plug this multiplication into that factor we start to get a bit of a gradient and in fact i think this is probably too small a number slider so i'm actually going to change it i'm going to make it 0.020 and that will give us a little bit more room to play with and you can see now that i get this interesting kind of effect that's coming through based on this point so if i go i'm just going to delete that i'm going to preview off all of these kind of items here and you see we get this kind of sliding attractor and we could change that slider to affect how that relationships actually working and as i move this point around these this attractor pattern that we've created actually updates so wherever the point is the cells actually get incredibly small so we could then go and set up a similar relationship for say a 3d viruno i might delete this 2d voronoi and delete this populate 2d and we're going to replace it with a populate 3d i'll delete the rectangle as well because we want to create a box now as we remember so i'm going to create a box right click set one box i'm going to start it at zero it's going to be 50 by 50 by 50 in the z direction like that and that will become the region of our populate 3d so all of our points sit within there then i'm going to create a voronoi 3d and the points will be these points here and the box will be that and we could then you know set this relationship up again plug in the points to there plug in the geometry cells to here and plug those population points into the center and we get you know once again a um i'll preview that box up as well a scale factor that gets smaller the closer you get to this point now one issue that we start to get if you kind of see over here is yet some overlaps in this geometry because our our multiplication isn't really working in the way we want it to the moment we scale above one in this attractive point scenario we get some kind of like clashing effects basically so there's actually a much more elegant way of setting up attractor points inside of grasshopper and it's with something called the remap component so the remap component is a really great way at squishing down the number values that we have in a certain relationship i am going to delete this multiplication component for now we're going to focus on what's coming out of distance so right now we've got a list of values and distance and i'm not entirely sure what they range between it looks like it's between 10 and about 60 and what we want to do is we want to squish those values down so they sit within a factor of like i don't know maybe 0.2 to 1. we don't want anything to be greater than 1 when we're scaling using this attractor relationship that we're setting up so i'm going to figure out what this range is we can figure out the range of a component by going to maths domain and clicking on the bounds component and that will tell us the minimum and maximum values or the domain of a series of numbers that we have or a list of numbers so i'm going to drop that under the canvas out of our numbers component i'm going to plug in into numbers here and i'm going to plug this into the panel and you'll see that our range of values they sit between 6 and 66 okay so we want to squish this domain down so the smallest number is say a 0.2 and the largest number is a 1. so it's almost like taking this big time line of numbers they sit on a timeline squishing them right down so it's 0.2 to 1. we can do that with the remap component so it's called remap numbers you can find it under domain again just here and the remap numbers has three inputs it has the series of values we want to remap those would be our distances we want to remap that list of distances and squish them down it has a source domain so that's asking for the domain of the current values that we have which is this we've already got this and then it's asking for a target domain so by default it's set to zero to one and we're going to effect that in a second i'm just going to plug in a few things to get us started so i'll delete this panel we're going to plug in our values that we want to remap oops values so from distance we're going to plug in our source domain which is you know the current domain or range of these values and then we're going to create a custom target domain so to create a custom target name we can go to construct domain and we can basically tell the domain start where we want the lowest number to be and what the domain end where we want the highest number to be so i'm going to make the domain start 0.20 because i want that extra decimal place i'm going to plug that into domain start and the demand domain end is one i'm just going to add a number slider that's 1.00 as well though and i'm going to plug that into domain end and then i'm going to plug this new domain we've created to be our target domain so now what we'll have is we'll have basically these values remapped so they're squished down to be you know between 0.2 and 1. so if we look at this distance thing look at number 8 number 8 is our highest value so remember the highest value in this domain was 66.37 so if i look at number eight that is 66.37 that's being remapped to a value of 1 because the highest point of our new domain is going to be 1. so what that means for this is if you have a really small value near the point its values are going to be remapped to approximately 0.2 and you have if you have a really large value the furthest point away from this attractive point we've created it's going to be remapped to a value of 1. so i'm going to plug in these map values to the factor and you'll see we get a really elegant kind of relationship we no longer have that overlap effect that we had previously by using this remap values component i often get asked by my students how to create animations using grasshopper of course you could just record your screen while dragging a number slider around but there's actually a really easy way to create really sophisticated and professional animations using simple tools inside of grasshopper we're going to create an animation of our voronoi tractor setup that we have from the previous tutorial before we start creating the animation there's a few tweaks that i just want to make to this definition i don't want to use a reference point from rhino i want to use a point that we kind of define inside a grasshopper that gives parametric control over this relationship so the way i'm going to go and create that point is by creating a point under the point under the vector menu and point and just go to construct point and this will give us the chance to cr construct a point from its x y and z coordinates so i'm actually going to override this point of reference here and just delete that guy and by default you know once again let's look at the inputs 0 0 0 are the values for x y and z which gives us a point at the origin of our rhino window so what i want to do is create a point that as i drag a number slider it will just kind of gradually move up to the top tip of our box that we've defined over here so if you remember when we defined this box we made it units whatever units you're working in so i want to make the maximum point 50 50 50. so we're going to just create a number slider between 0 and 50. i just want to quickly talk about creating more sophisticated number sliders so previously we would just type in like you know a 50 and then we get a number slider that's actually between 0 and 100 but we can control the domain of this number slider really easily i could type in the start of the number slider that i want it to be at the lowest value i could type in a smaller then and then type in a 50 and then i'll get a number slider between 0 and 50. i could also type in 0 so the smallest value i want in my number slider say 25 is like the value i actually want it to be set up initially and then small then again for a 50 for the highest and what this will give me is a number slider that's between 0 and 50 but starts with a value of 25 and i'll hit return like that and then of course you've seen me do this before but if we go and add some decimals to this so if i say 25.00 um i will then get a number slider that sits between 0 and 50 has 2 decimal places and starts at 25 like that and this is the number slider that i want to use in this little exercise if you ever want to change your number slider values just double click on the number slider name and you get a series of options that enable you to change the rounding to like integers even odd numbers the number of digits you want or decimal places you can easily double click and change the domain and the range and then of course the current value that it's at i'm going to now go and plot well i'm going to set this to 0 i'm going to plug this into the x y and z coordinates so now what we'll get as i move that guy up is we get a nice relationship where that point moves through space and updates all of our attractors on a diagonal kind of vector just like that and it's the size of our box so it fits perfectly within our attractor so we want to create an animation of this right now if we try to create an animation it'll look like you know a grass up a preview we want to dress this up a little bit so it looks kind of like swish and professional inside a grasshopper we can actually make geometry look a little bit nicer using something called the preview component so i'm going to double click on the canvas i'm going to type in preview and there's a custom preview component here so this can be found under display and under preview just here if you ever get lost and what the custom preview component takes in is it takes it in a geometry to preview and then a material that we're going to apply to that geometry so if i plug in this geometry here by default the material is actually pink i'm going to preview this guy off here and this takes in something called a color swatch so a color swatch will enable us to change the material or the color value of the geometry we're displaying through our custom preview component i'm just going to type in swatch color swatch here and it's really easy to use and kind of fun to use component it's just got a color and then that goes in there's the input so i could change it to white if you want to change the color you just click on the color swatch and a little kind of color menu comes up if you want to change the color adjust the hue so i might go with like a nice shade of blue if you want to change the saturation just pull that up and drag it across and of course you can just drag around here and you notice it updates live in your rhino window as well so one thing to notice with your custom preview component is if i preview this off you'll see it disappears but if i now go into rendered mode you'll see that my custom preview is still here despite being turned off so custom preview always displays in rendered mode unless you right click and prompt it to not display and render so if i click off render it won't appear we actually want it to display in render for this little exercise because we're going to do an animation of this but basically if you're using render mode just be aware that custom preview is always going to appear unless you specify it off so our animation is going to look something like this we're going to kind of slide across through here all the way up to there and i might actually delete that little reference point that we had previously and i just want to make sure that you know this is a nicely centered animation like that so our animation is now going to basically sit here and we're going to create a bunch of frames that we can slide through so the way you create an animation is actually the simplest part of this whole process on any number slider you can right click on the name and you click on animate and what will appear is something called the animation controls window so under animation controls we can specify where our animation is going to save to what kind of format it's going to save in the resolution the number of frames and then we get a small preview of what that is actually going to look like so we're aware of it so because i'm in rendered mode i'm going to get a rendered preview a lot of your settings will be a little bit different to mine because i've changed the defaults but i'll talk through a few of the things i think you should change the first thing you should do i'm going to create a folder to save all these in because what the animation actually saves that is a collection of frames or image files i'm saving mine as png files and these could easily go and be turned into an animation in say photoshop or adobe premiere on the desktop make a new folder i'm going to call it animation 0 1 and i'm going to select ok and that's where it's going to save my animation to to animation 0 1. i think by default it's a bmp file just change that to a png file for the purpose of this exercise i've got my viewport set mode set to perspective which is just like the view you're currently in i have my resolution set to 1920 by 1080 so the standard resolution of a computer display and the frame count is currently set to 100. this is the number of images that your animation is going to generate i'm going to leave that as it is but if you want like a longer animation or a higher frame rate you want to increase that size so now i'm going to hit ok and what will happen is it's going to create a frame or 100 frames for this number slider at a series of intervals so you watch as i hit ok the number slide is very slowly ticking up and it's going creating an image file for every single iteration of these frames in the top left corner on the command line you see kind of like an estimation of how much time is left to create this animation as it runs through so it'll take a little bit of time for your animation to be done but once it's completed you can navigate to the folder which is on my desktop i've saved it and you'll see here you get that collection of frames that dictate your animation so then you can go into you know a photoshop or you know an adobe premiere or something like that and you can convert all of these really easily into a video that plays your animation and shows kind of that you know power of grasshopper that algorithmic relationship that you've created completely in play let's take a look at the graft flatten simplify and reverse tools in grasshopper and how they can be used on objects lists and data trees let's start by creating three simple lines in rhino and reference them into grasshopper so i'm just going to draw a line like this and i'm going to rotate it with my gumball you could rotate it with the rotate tool if you want i'm just going to move it to the origin point like that and then i'm just going to make two more copies of it so one two three like that so we've got three lines just sitting in rhino and then we're going to reference them into grasshopper so we want to do this using a curved container it's going to drop a curved container onto my canvas i'm going to right click and go set multiple curves and then i'm going to select these three curves hit return so we've got them referenced nicely into our grass upper definition i'm going to create a panel and let's have a quick chat about these curves so our three curves are referenced into one grasshopper component and each curve is its own object however when they're all referenced together they create what's called a list so we've talked about lists in previous tutorials lists can be thought of as collections or groups and they're important tools in grasshopper as they allow us to control collections of data and match objects to one another from separate lists as we saw in the last tutorial we matched some voronoi cells to distance number values to create our tractor point algorithm so far we've discussed objects and lists in this tutorial series but there's one other important data structure that we need to get familiar with and that's the data tree data trees could be thought of as lists within lists so take our curves for instance what if we wanted to divide these curves into a series of evenly spaced points i'm going to double click on the canvas and use the divide curve component which is right here and this is a component that will enable us to divide any curve into an equal length segment of points so you'll see here we've got a curve input the curves we wanted to divide the count which is the number of segments we want to divide and then kinks we're not going to worry about the kinks in this tutorial so i'm going to plug the curves into divide curve and by default the count set to 10. i'm actually going to maybe just make that five for now just so it's a little bit more simple so we have three curves one two three and each of those curves is divided into five points so let's see what happens when we plug our points into this panel we actually get a list and another list and another list so now we've got three lists sitting within our overall data and this is what we call a data tree so our data tree is organizing the data that we've created in grasshopper in a way that's easy for us to manipulate and understand we now have three lists sitting within our overall list and each of those three lists relates to one of these three curves so you could almost think of it as groups of points within the overall list so we've got three curves which means we have three groups of divisions and within those groups we have six points we can also view this using something called the param viewer i'm going to drop a param viewer onto our canvas we're going to have a look at this so we see here we have data with three branches in our data tree so we have one group of points which is related probably to this curve a second group of points related to this curve and then a third group of points related to this curve data trees are sorted using something called path numbers and this helps split our data into separate lists the path numbers are seen here on the left of the parameter viewer if we wanted to locate point 3 in the second curve we would just look inside path 0 comma 1 and find item number 3. when using grasshopper you may have noticed some of the icons that appear when you right click on the input or output of a component these tools are data management tools and they help give us greater control over the data we are using in grasshopper let's talk about the reverse option first the reverse option simply reverses the order of the visible list so the data tree itself is not going to be reversed but the objects on the lowest branch of the tree will which is these lists so what will happen is item number five will become item number zero and zero will go to item number 5 and vice versa and we'll get a reverse list i'll click and you'll see it happens so you see 0 0 0 drops the bottom and 0 0 99 goes to the top in this instance i could un-reverse that and we'll have our list back to normal if we reverse the curve back here that will have a flown effect and suddenly we have this curve being the first in the list this being the second and this being the third which then divides these curves up which means you get a slightly different data structure over here the next one i want to talk about is simplifying simplifying removes the extra zeros from your data tree's path numbers so these path numbers we were just talking about before they generate an extra zero every time a data tree gets manipulated so you see how i've got a 0 0 0 1 and 0 2. if you're working on a really complex algorithm it's not uncommon to find yourself with lots of zeros so 0 0 0 0 1 0 0 zero zero two making your data harder to read and that means it's harder to match with other trees and lists to mitigate this problem it's recommended to use the simplify option to remove these zeros and clean up your path numbers so you see my path numbers now change to 0 1 and 2. let's next talk about grafting i'm going to make a copy of this curve component we're going to do a little algorithm down here to show off how the grafting tool works so if i create a parameter viewer we can kind of see what's coming out of this curve that we've got here which is a flat list of data with no branches and no data tree graphing is a way of turning a list into a data structure if you graphed the list of objects the objects will then be put onto their own lists so let's watch this in practice i'm going to actually graph using a graphed tree component here okay rather than right clicking showing graph just so we can compare these two so i've got my graph tree here and let's create another param viewer and see what happens so you see the comparison here between this flat list of data with one branches versus the grafted version where every single curve that we have that we've referenced in is now put on its own branch so we now have a data structure where these curves are on their own branch in the list where this gets interesting is when you try and operate on a data tree so say for example we wanted to loft these curves i'm going to use the loft component which works the same way as the loft works in rhino so we can loft these three curves in this list that we have here and we'll get a nice surface basically it's reading all three curves in that list and then it's lofting them if we create another loft component and we loft this grafted tree i'll just preview that one off so we can see you'll notice that we don't actually get a loft from this so why is that grasshopper operates on a list level so what it's doing when we loft these curves that aren't grafted is it's finding these three curves in a singular list and it's saying okay i'm going to run a loft option on these three curves whereas if we look at our data tree they're all on separate lifts so it's running the loft on this curve on its own then on this curve on its own and then on this curve on its own grafting can also be used to match data trees together let's take a look at a quick example i'm going to copy these guys from the top here again and we'll drag this down to the bottom so we've got our curve and our divided curves again we could go and create maybe just a circle component like this i'm going to plug the points coming out of the circle into this plane here and i might make the radius a little bit bigger let's make it 50. see what that looks like well they're a little bit too big let's make them about 15. there we go perfect and then like we've done previously in the previous tutorial let's maybe scale these circles so these circles are still a data tree you can kind of see if we have our parameter viewer this data tree is carrying along the whole way through based on the division of curves so we've got our three kind of lists within this starter tree and they relate to these three lines that we've drawn initially and i am going to scale these geometries i'm going to scale them from the center points that we have coming out of divide curves so they're all just scaling based on those points based on their relative points so in this sense we've matched up these two data trees right we've got a data tree of points with three branches and then six points on each branch and then we've got the same we've got a data tree of circles with six circles on each branch and they're basically operating on each other now we can actually use graft to change how we go about scaling each of these circles that we have here i might preview a couple of these guys off like that i am going to just create a panel and into that panel i am going to type in the numbers 1 2 and 3 like that we're going to turn this panel into a list to turn the panel into a list just right click on the panel and select multi-line data and you'll see straight away the panel is assigned some values so we've now got a list of numbers coming out of this panel i'm going to create an integer container so that's this container here i'm going to plug those numbers into here and we're basically going to scale these circles based on these integers but basically what i want to do is i want to scale the circles that are on this curve by a value of 1 the circles that are on this curve by a value of 2 and the circles that are on this curve by a value of 3. if i go and plug this into the factor it won't do that right now what it's actually doing is it's scaling the first item in this circle list which is this bottom circle here by a factor of one it's scaling the second item by a factor of two and then it's scaling the third onwards by a factor of three and then it's doing the same for each of these curves and that's because we have a little bit of a misalignment in our data structures if we want to match these data structures we can easily just use the graph function so the data structure that we want to get to is something like this where we have three branches and we're able to operate on each of those branches using this panel so let's go and create another param viewer i'm going to plug that into there if i right click on this integer component and i graphed we now have a data structure that matches up with this parameter viewer so now what's happening is for the first group or for the first group of data coming out of the circles we are applying the first branch from this data structure which is one so we're scaling by one here then for the second branch we're scaling by this second branch which is two and then for the third branch we're scaling by the third branch which is three we could then go and loft these curves like this and you'll see once again the loft only operates on that list level so it's taking the three curves i'll plug that into here coming out of the first branch and lofting them all together then the curves coming out of the second lofting them together then the curves coming out of the third and lofting them together as well so let's talk about the last option we've discussed reverse we've discussed graft and we've discussed simplify let's talk about flatten flattening is probably the easiest of the options to understand flattening simply turns any data tree into a long list and removes the data structure entirely so up here i've got a data structure but if i select flatten you'll see my data structure is completely removed and i just have one flat list of 18 points we can visualize this with a panel we no longer have a data structure here we've got a list of flat circles and then plugging this into the loft component means it's going to try and loft every single one of these circles so you see it lofts from here all the way around and then it goes back to the next curve again and all the way around because we've now got a completely flat list of data so hopefully that gives you a bit of an understanding as to how data trees work and how to use the graft flatten simplify and reverse options inside of grasshopper data trees enable you greater control over your designs in grasshopper but the only way to master them and understand them completely is to keep practicing possibly the most powerful thing about grasshopper is its vast collection of plugins that extend rhino's capabilities which opens up limitless possibilities for your design let's take a look at where to download plugins and how to install them the best location to download any grasshopper plugin is foodforrino.com food for rhino collects most grasshopper plugins ever created on its website and you can easily search for any that you're looking for i'm going to try and install the anemone plugin which is a looping plugin that enables to create loops within our grasshopper algorithms so i'm going to type anemone and i'm going to hit search and the first one with this kind of like anemone looking thing is the one that i want to select i'm going to click on it and it'll take us to the anemone plug-in page on the food for rhino website so there's a few different options down here as to what we can download you always want to try and download the most recent version which would be anemone 0.4 so i'm just going to hit download and i'll get a little gha file some plugins have more than one file and you might get a zip file that you need to unzip so what do we do with this gha file we need to copy it into what's called the grasshopper libraries folder so if we flick back to rhino and we have grass or open you can find the libraries folder by navigating a file special folders components folder and you'll see you get this folder called libraries that you're stuck in i've got one plugin installed right now called bifocals and this enables me to see the names of each component above the component on the canvas what we want to do now is place our anemone plugin the ghaj file into this libraries folder so i'm going to go to my downloads i'm going to right click on anemone and i'm going to cut it go back and now i'm going to place or paste this file into the libraries folder now before you get started there's one thing you need to check always right click on the gha follow whichever file you're copying in and check properties you need to unblock the file before you can use it inside of rhino so sometimes you get this warning in windows this file came from another computer it might be blocked to help protect the computer you need to hit unblock and go apply otherwise graspable won't be able to load the plugin so generally speaking any plugin that you download you want to copy and paste the files into the library folder once you're done copying and pasting you then want to close rhino and grasshopper and then restart it grasshopper up again and you'll see we have the anemone plugin installed into grasshopper some of the plugins i recommend downloading include the anemone plugin which enables you to create loops and simulations the weaver bird plugin which gives you greater control over mesh geometries in grasshopper the pufferfish plugin which is a great suite of tools for tweening objects and creating complex geometries and the chromodorus plugin which allows you to create isosurface meshes grasshopper also comes installed with the kangaroo 2 plugin which is a fantastic physics engine you can use in your design process there are a whole series of other plugins that are also fantastic tools you can use in grasshopper now that you've got a base understanding of how grasshopper works let's discuss five helpful tips to improve your grass upper workflow often you'll find a new component in a grasshopper definition but it's not always obvious where it's located in the grass upper toolbar if you hold down control alt and then click on a component with your left hand mouse button a collection of red markers will appear on the grass upper canvas to show you where the component can be found [Music] locating a specific component's geometry in grasshopper can be hard if your definition gets quite complex luckily there's a zoom tool that helps us locate the geometry related to any component simply select on a component then right click on an empty spot on the grass upper canvas and select zoom and you'll be zoomed in to the component's geometry straight away sometimes you want to use the data being output from a component without relying on previous components in the definition if you create a data container of the same geometry type as an output you can plug it in then right click and select internalized data this breaks any parametric relationships and stores the data in this component the component can be reused or even copied and taken to a new grass upper file grasshopper algorithms can get messy very quickly and it's easy to get lost in the sea of wires and batteries so it's important to organize your definition in a way that you or anyone else who uses it can easily understand which parts of the definition are serving what purpose the easiest way to do this is to group your grasshopper components based on a function they might serve by selecting them right clicking somewhere in the grasshopper canvas and choosing group you can easily name the groups so it's clear what the function of any group is doing you could right click on a group and then just type in a name the sketch tool is a handy tool to leave notes for others in your grasshopper file just click on the pencil icon below the component tabs and start drawing if you're handing your grass up a file to someone else it might be helpful to leave them a few tips explaining your definition hopefully you found these tips useful and you can introduce them to your own grasshopper workflow
Info
Channel: Grasshopper Tutorials
Views: 29,707
Rating: 4.9817977 out of 5
Keywords: grasshopper tutorial, grasshopper, Rhino Grasshopper, basic grasshopper, grasshopper plugin, grasshopper easy, grasshopper beginner
Id: zDDVeDldvaI
Channel Id: undefined
Length: 62min 13sec (3733 seconds)
Published: Mon Nov 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.