Grasshopper: Using Graph Mapper to modify contour curves

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so like I said I wanted to explore some of the options that you have for this assignment and some of these you'll be familiar with in in general like from rhino but we're gonna look at it from a grasshopper person perspective so and I'm just gonna work with you just made just a kind of generic surface rather than anything special but you know you can you can think about how you put this together with the constraint that this be hexagonal so remember from the 3d printing exercise how we cut things down eventually you're going to need a surface that that conforms to those parameters so you'll need to cut it down in some fashion so that the GA when you're milling it knows where the boundaries of the surface are or the your earpiece are and I mean it doesn't have to be on the bright side it doesn't have to be closed be reps is that that doesn't matter too rhinoCAM but it does have to be a surface or a mash of some kind so this is obvious depending on the scale that I'm or though sorry the units that I'm using this might be too much one of the constraints on the assignment is that the maximum height be two and three-quarter inches and the reason for that is just simply because we have to cut this thing out of your material and we don't have good bits that are longer than than three inches so we want to and we want to make sure there's some clearance above your material when we cut it out so that's just a limitation based on the properties of the machine and the tools that we have so one one technique that you might be familiar with especially if you've done any laser cutting of topographies for your models is contouring so that is something that you can do in grasshopper as well so if I pull in this particular surface let's see here and I want to contour this in different ways there are a couple different components that will do that you can contour a bee rep or mesh and then there's this other version here and they have different parameters or inputs to them so we'll look at these and compare them contour X and so the first takes a shape which would be what you're what you're wanting to contour so that could be your input mesh or or B rep a point that indicates where the contouring should start the direction this is perpendicular to the actual contours and then the the distance between contours whereas the other one it takes shape a plane which then the the contours will all be parallel to that plane and then either offsets or distances between them so these would be this would be if you wanted to do some kind of abnormal or irregular contouring whereas this the distance between contours is set in our case here our surface is our shape and the point would be just any kind of reference point it could be a point on your surface or otherwise if I put one on the corner of the surface pull that in here that specifies the starting point the direction by default is the looks like the z-axis so we'll leave that for the moment and then the distance between can be up to you I'm working here in inches and this not sure what kind of distance makes sense but we can use a slider for that so ooh this here so you can see once I've done that I've got some pretty interesting contours based on the curvature of this surface so I can see that they're pretty close together where the where that's pretty steep and as it's not so steep they're more spread out just like you would expect with topography or something like that so if you were to play with this well obviously the distance between them changes but this is if you can if you think about it since the Z the direction for the contouring is the z axis that means you if you think about it there's a there's a vector pointing straight up and these contours are perpendicular to that vector that points straight up so that the contours themselves are parallel to the XY plane in this scenario now if you wanted to play with this more visually what you could do is create a curve that becomes your direction so you know you could draw that maybe from the side and then you can pull that in as a curve curve and you can grab its endpoints and then use vector to point now the there's a shortcut to this you know this is one way to do it to generate a vector that corresponds to that curve or if you another shortcut to it is if you first convert this to a line so using the line data type and then and then convert it to a vector which will that's that's kind of a way to do this implicitly so I could actually click connect to this directly to the vector input for the direction if I want to see that vector I can do that as well but you know that's just gonna create an arrow there that confirms that that's where my vector is pointing and you have to think about this now in terms of what is the plane that's perpendicular to this vector that's the plane that the contours are now drawn on you could turn on points in Rhino for this and then you could drag it around and see how that impacts your contouring depending on you know how that is in relation to the curve you're lying there so just to reiterate this the set of components here does would do the exact same thing as that implicit conversion from line to vector so what this gives you is a bunch of curves you have a treaty here they're grouped by sections so what that means is if if you have a volume that is enclosed or that that folds over itself there might be cases where these contours intersect the form at more than one place and so the way that this data is output those if there are multiple places where there's an intersection resulting in multiple intersection curves those will be placed on the same branch so that you can treat them together if you want to if that's not happening then you can just flatten this and and be fine now what that could theoretically be those individual curves could you could call them tool pads now that's not going to work for a surface that looks like this because this it bends over itself and so there's no way a bit if it's coming from above is going to be able to get to those points underneath that overhang so that's something that's a limitation of our mill 3x2 smell any 3xs mill is that it's not going to be able to get under cuts it's not going to be able to do that because it can can't get there without going through the material above it so you may need to you know adjust your surface or whatever if you've got conditions like this but most of these curves could individually these contours could individually be tool paths that the that rhinocam uses with the engraving tool the engraving pass to to engrave your material now that would be you know after it has cleared out all of the you know it's it's already roughed out your main bulk of your material and and all your left is with the surface so you probably would have already done a parallel surfacing on this to get your smoother surface and then you could come over it with these engraving tool paths however since they're actually at the surface you know they're they're they're co-located with that surface they are are right at the same level the tool path it would probably still show something like there would still be some minor cutting that happens but but if you wanted this to really have an impact on the result you would want to change the Z so that you know it's cutting into the material to some degree now just because I mean this isn't terribly interesting on its own simply because it's you know it's the same thing essentially that a parallel finishing pass does but with grasshopper you could start to play with this in various ways so for instance have we talked about the graph mapper at all did we do anything with that so the graph mapper is an interesting input and it's on your input tab on the while parameter tab input drop-down it's called a graph mapper and what this does is it creates this input box and it looks pretty boring until you right-click on it and then if you look at the graph types submenu you'll see that there are a bunch of different built-in types of graphs and what this dialog will let you do is play with the particular definition of that curve and so this should take you back to your you know graphing days in high school where you were you know taking a function and plotting it on an XY graph so this would be some you know kind of basic sine function and there's a you know there's gonna be some simple some basic formula for that you know y equals sine X or something like that and what you have to think about is is basically what this graph mapper is going to do is it's going to take whatever the input is which would be a number of some kind and it's going to plot that number on the x-axis so and this is this the x-axis of this graph here on the screen so the incoming number would get plotted along the bottom and then it would go up to the curve and find the y value that corresponds to that x value and then it's gonna spit out that y value on the other side so if we wanted to experiment with this for instance I could get a slider and plug that in here and you can see there's a red line now that shows that it's picking this X this position here on the x-axis right in the middle and as I move this slider it shows me you know where it's slicing that curve and where it's intersecting here that's what's going to come out the other side so if I put a panel here you can see that it's saying that it's coming out as four point seven so as I scale this now as I go down maybe I want to add a few decimal places to this so I can see better what's happening here so now I can scale smoothly through this and I can find that lowest point there it looks like it's 0.21 right here and it's going if I swing over here it's gonna be point to one again but then it goes all the way up to 0.92 so you see how it's mapping everything on the x-axis between zero and one to what it finds according to the function that you've defined or the graph that you've plotted it will find the corresponding value on that graph in the y-axis and it will spit that out on the other side does that make sense so we can use this to our advantage to modify any number of different types of data it does need to be numeric and unless you want to really mess with it you may have to scale your data to fit into the zero to one spectrum so if you remember we have a remap component that will scale numbers to a given target domain so we could do that for instance we'll use a remap this is going to scale whatever values are given to it from the source domain to the target domain the source domain and target domain both default to 0 to 1 but if we give it a different source domain such as I don't know the well it depends on what numbers were giving it but let's let's experiment with the z axis of these curves so what we can do with each of these curves we if we wanted to modify these curves we would need a way to modify points along those curves so the first thing would be to divide up these curves into points divide curve and you can use any number of ways to divide your curve that's interesting I think I probably wouldn't use this one because the curves vary in length so maybe a better one would be divide curve by length or by distance and then you have to specify a distance so that might be so what what we'll get now is a more regular grid of points because now these are separated by lengths along the curve instead of by by a number of points regardless of the length of the curve so it's complaining at me here because what yeah no it's it's mainly because there are going to be some of these contours that don't actually have any some of these sections here anyway that don't have any data is my guess if I flatten this it may resolve it no let's take a look at this see what's in here all of those are good and said to an instance of an object well oh I wonder if dropping this down I think yeah once I got small enough there it was able to my guess is there's a curve so short here that no point can actually fall on it so that's why it's getting upset so what do we owe but it doesn't output anything that's weird it was just doing it before around up and down I just have heard like before Oh actually yeah and I out here well the arrow is something that we made oh okay so divided length are you using divided lengths are using divided distance okay I was using one that belongs to something else so divide the default one divided like this this one so what you're getting okay yeah okay yeah I don't know let's see okay I've got another plug-in so that's that's so this is actually producing more points so I want to increase the range here so that gives us points to work with so thanks for alerting me to that okay so if I want to modify these points now I might want to extract like if I just want to modify these points in the z axis I would want to extract the Z component of each of these points so when we want to get the components of a given piece of data there's a certain type of components that we use remember what those are I want to break down something into its parts there are similar components for domains for vectors for B reps trying to think where we've used that most for planes basically if we wanted to or what kind of components to use if we want to make a point if I want to build a point out of its constituent parts well that that would generate one but if I just have the components like if I just have the x y&z components of it for instance no so I'm talking about the class of components called construct and deconstruct components so those are going to take kind of the most elemental components of a piece of data like a vector has is gonna have at least a vector that we're using are gonna have XY and z components and a point is gonna have XY and z components a plane as an XYZ component that defined its origin but then it also has a normal vector so a domain has a start and an end or you know a domain squared has two dimensions to it so we can deconstruct a point and that will give us its Z component and now what we could do with this let's see well I guess it depends on on what range of things we wanted to do we could we could kind of scale this Z component down now that I'm thinking about it though that this is probably not the easiest way to do this easier would just be to move the point in the Z dementias so but that so that doesn't do a good job of illustrating a mapping well let's just look at it without the mapping that without the remap and then and we'll just go with well we do have we do have to have points to translate here all right so basically what we need in order to to get a value out here basically if we wanted to use this function here to transform the Z component of each of these points we need some kind of input to give it for each of those points and that could be simply a range that we generate or it could be the actual Z component value now these Z components if we were to look at them are going to be quite if there's going to be quite a range to them if we look at the bounds of C well we're gonna get a bunch of different domains here we would have to flatten this if I look if I flatten this anyway the domain here is negative 10 to positive 10 so we've got quite a range of numbers in the components for these points so this is theoretically something that we could remap so basically we could say we can remap these numbers from this domain this will be our source domain to the target domain which is 0 to 1 and we'll feed it the actual Z values as our values to remap now yeah that shouldn't be a problem and then those remapped values become our input to our graph component so basically what we're doing it with this is first we're taking all of the numbers that are the Z components of our points we're figuring out what the overall domain is of those numbers so negative 10 to 10 and then we're remapping all of these numbers so that they fit between 0 and 1 proportionally because that's the target domain here so now that all of those values are between 0 & 1 like if we look at this now you can see here that they're all between between 0 & 1 or at least they should be the now when we feed those values into here they're each going to be mapped onto this graph and we're going to get a corresponding value according to this function that we've defined so so I've taken a Z Z component from each of our points and then plugged that entire range of numbers flattening it into into the the bounds component which is going to give us a range for the entire set of points not just one of these contours okay so that puts that that puts all of those values in that range from 0 to 1 this remap does and then they'll basically all gonna fall along this zero to one range here and so what we're going to get out the other side is the corresponding values that this function defines in in the graphs y-axis so they're going to look similar because they are in the same range from 0 to 1 yeah uh-huh uh-huh you're so [Music] so input so basically so it's basically the the way that so you've got allergies Wow over yeah let's see what this does here and so far this is this is pretty much just a numeric exercise so what we want to do is actually take the result of this now and use that to modify our Z value or actually to become our Z value so there's a couple different approaches we could take since we remapped these values what we could do is just map them back the other direction so use another remap component except that now our bounds is the target domain and our source is 0 to 1 and so these values then get plugged in the values from the graph mapper and now we can reconstruct our point using the new values so constructing a point will just grab the for the construct point grab the X&Y from the original back here so x and y can just translate directly and then the Z is the result of the mapping so the construct point just gets the X&Y from the original deconstruct component because those aren't changing but what we're doing here is we're remapping the Z value according to this function is that working all right okay that may be results of your graph so that's we were trained in that okay right so yours looks different just because of the direction of your contour this quite a bit because the range as you she is 19 - is pretty variable in the and so if you think about it we should maybe you helps to draw this on the floor you know I have I have my service curve right so if this is my surface I've got this you know this curve that follows that surface now I have divided it up into these different points and those different points each have either Java that's the Z of X here Y here and see here each of these have a C access value so maybe this one is 1.2 1.3 and so we have that range of values the remap basically says okay I want to treat 1.81 since that's the spell value I want to treat that as zero as we're remapping that into the range 0 to 1 so remember one point 1 to 1.5 to 0 1 then those resulting Maps values get fed into that graph so let's say that since 1 point 1 maps to 0 that would get mapped here the graph amount of curves is 0 so we go up here and get that value and then we're taking that and we're replacing the result so maybe this is 0.3 we're backing that 0.3 back to that the name so 0.3 here on this domain is going to be somewhere around here so maybe this gets mapped it doesn't get mapped a whole lot because this this range is impaired so if your if your surface varies a lot in the z-axis system this range here is going to be a lot bigger and so your transformation is going to be a lot bigger now if you wanted to to have more of an impact on it you need to change what your target domain is so right now we're just going back to the domain it was in but we can we could choose a different target domain so for instance we could build it we could construct our own domain construct domain and then just attach a couple different sliders to this so maybe one of them is like you know negative five to zero if and maybe we want this to have bunch of decimal places that could be our start and then another one and it might be 0 to 10 and set that up here and now that becomes my target domain so now what I can do is I can I can change the degree of impact that that's going to have on the z axis but what your what the graph mapper is doing is it's introducing an additional undulation if you will to each of these lines so because it's values and the frequency of that graph etc that the transformation is going to vary across the length of the curve based on its original Z height and introduce a whole new level of curvature you can take this back to curves by interpolating these points so back here when we first divided the curve we got a tree that included one branch for each of these curves that we divided so since we still have that tree structure throughout we can we can use these points which now are back on these branches like this we can interpolate curves through those points to generate new new curves so interpolate [Music] not interpolate data just interpolate is going to take a list of points and draw a curve through them now something you didn't like about this so on one of these in any case it did not have enough data to go on but if we look at what it did go on or did create I have now these curves that go through all of those points now it got really confused where where my surface doubled over on itself because those points are are pretty convoluted if if it didn't double over on itself it would be a spinet curve now my guess is for where it's it's having an issue down here because down here at this corner there's no it's trying to divide that surface there but it's only getting like one point out of it so that's that's where it's complaining here but that's another way to get curves now the problem with this now since that that's pretty divorced from our original surface that's not going to be pretty helpful or be very helpful if we want these tool pads to be expressed on our surface right like these are all very far away so while that's a way to you know manipulate a surface because you could generate a surface from these points as well as another way to visualize this you know that that might be interesting we can also use the graph mapper in a more basic way to to give us just various undulating values that we can use to modify these points just in relation to where they're at so what we can do is generate basically a sequence of numbers that correspond to each of these Z values or each of the points rather and and then just move those points so we can ignore the individual components and just work with the points themselves what we need then is is basically some number to use that will once fed through this graph will be translated in a way that will give us kind of a modified result so to do that we could use a series basically we need we just need a number in this range for each point now it can actually go beyond those range 0 to 1 it will just act as if this curve goes on indefinitely and it will map that point wherever it lands so we don't have to downsize these values to fit between 0 and 1 because it will you know it will continue to use this graph even beyond what's visible but ultimately what we need here is for each of these points we need a value and the series is going to give us that value we so what we want is the length of these branches they're the length of the lists rather on these branches that will give us a number of numbers that we need and in the series component will give us those numbers so with a list length component we'll get a length for each of these branches that becomes the count of numbers that we need so now we're back to a data structure that looks pretty similar to our points here because we have one number in each case so basically what I've got is some branch one branch one has one item on it so it's just going to have the number 0 the second branch have maybe has two items on it so it's gonna get 0 and 1 the next branch might have three or maybe five numbers on it so it's going to get 0 1 2 3 4 5 in the series component and then those values are going to get plugged into our graph mapper component and we're going to start to see a sine wave because of the distribution of these numbers along that x axis in the graph so well we can look at this here so the the number of values that are generated corresponds to the number of items on each branch so the first branch has one two three four looks like there's two floors there etc and then they get longer when where the curves are longer so some of these are pretty long so when we plug those into here we're going to get values between zero and one on the y-axis that correspond to these x values and they we have as many x values here as we have points so we can use the resulting number to actually move those points in the z axis and that's going to get us variation just in relation to the surface so if I move our points point geometry then I need if I want to move them in the z-axis I would use the Z unit vector so let's see let me spread this stuff out of it yeah so the output from the graph mapper becomes now we wit we may want to modify this but if we just use 0 to 1 for now this will create as a vector in the z axis that has the value that's results from the graph map for transformation the points the points these are from the divided length so and then we can interpolate these points just like we did in the other case and you should see pretty clearly that sine wave now expressed in each of these curves so yeah you can see now how that sine wave now has been spread out along each of those curves [Applause] uh-huh I mean these are pretty different than mine too right so basically all we're doing now is we're just using that he's different are now defined by adjust these these regularly appearing numbers so because we've generated equally spaced values that we're feeding into the graph mapper or getting equally spaced portions of that graph mapper function with which to adjust the Z value of these points I feel like I'm losing you guys is there is there something that's still kind of hazy for you guys okay no no problem I'm moving too fast I need to slow down yeah so if it's only got one point to work with it can't draw curves through that but if it's got the two to it then it's okay so what you would have to do is probably either you could use shift without a wrap to drop one item off the list on each end you could one one simple change might be simply to adjust the location of your point here so if I move this point so that it's right off the surface for instance nothing more yeah if you it's possible that if you changed this enough so that it's you know it's wide enough for it to actually and or if you reduce the distance between so that it can fit more points sorry but ya reduce the distance so you know it's the leaven issues so I'm not sure hmm yeah I mean I got it just by playing around with that until the starting point and the vector gave me something that worked now this is kind of interesting here I've got like a really regular pattern here and then that shifts part of the way down so what's going on [Music] so you could think about this another way to think about this is it's taking it's just taking the the values that I'm giving it and it's and it's just it's almost like if you you hit the table and if each of our points were grain of sand it's using this function to determine how far each one is jumping up there or down in relation to the original position of each of those points but you know it's very strictly controlled by this graph if you're adding noise to it if you will you're adding noise to the numbers adjusting them up and down according to this function so you could you could start to mess with this by looking at what would happen if you changed the direction in which you're moving them you could give it an entirely different vector probably wouldn't look quite as I mean we could try like to see what happens if we put the X in there instead it's gonna just vary it along the x axis instead of in the Z so these points are you know are all close to that surface but they've been moved along the x axis instead and so that might actually be pretty interesting because that bit would be moving in and out if you think about it like a ball no spit moving in and out along that curve it's gonna be engaging the material to different degrees as it moves along and so you might get a pretty interesting pattern out of that another thing that you could do is you could actually add the vectors together so I could do this in both Z and X and then add them together because you can actually add vectors and then use the results and so now I've got there basically tilted because they're moved in both the X and the y are starting the X and the Z so now they're at an angle so and then you can play with this - there's lots of different graph types so you can get some real noise if you you know you use something like like this guy though not sure what's going on here have enough points for this to work another thing that you could do is reduce the step size here so the if you think about it these numbers are just you know one zero one two three so that means I'm actually getting this value here and I'm getting this value here at the end and then it's just repeating so if I reduce this step size then the sampling of this graph is going to increase so maybe I use a slider here I can change the step of this and look at the result and then start to decrease this step and I probably will see more of a variation than a little bit maybe this needs to be increased now good so that's not quite as interesting with this here this this particular one might be more interesting with the other method that we messed with they could also have something to do with the point density so if I divided this with a smaller distance here's oh dear anyway their various other one is secretly messed with so that's just one approach we'll next time we'll take a look at some other ways we can generate curves for toolpaths yeah like the assignment says although when you get back from Spring Break I want to see what kind of ideas you have about what you want to do so hopefully over Spring Break you could take some time to to play with how you're generating curves for toolpaths in addition to coming up with whatever the overall form is and then you know once you've taken a stab at that I can sit down with you and see if you know if you're getting close to what you want and what you might be able to do to move closer to what you want or give you any other help that you might want so that then the following week or over the course of the week following the Tuesday after Spring Break who can get this milled so you know you'll want to get on the schedule pretty quickly so and before you can get on the schedule you'll actually need to be able to give them some geometry so it doesn't necessarily have to be the final geometry but they do need to kind of have a a good idea ideally you know you're giving them one iteration of your geometry and that might be the overall form or whatever and then you're maybe just giving them a different set of curves if you've taken time to refine them or at least maybe it's you've got a shape and you've got curves and then they can just kind of swap in you know your final geometry and regenerate the tool paths so that you can you can give them final geometry when it actually comes time to mill but they do need to know kind of what they're dealing with so they'll need to know what material you're working with and the it's dimensions so basically you're gonna start with a block of you know material whether it's you know brick just white whether it's climate or a hardwood or just a softwood or MDF whatever it is that you're working with you'll need to laminate that up probably unless you're getting thick wood I need to laminate that and then actually give them the exact dimensions of that block of laminated wood that you build so that they can model it in rhinoCAM so that they know what they're working with in terms of what they have to mill away and so that in addition to your geometry will help them figure out what kind of tool paths they need to set up for you and then your final the final tool path will be this engraving well maybe not the final because the final will probably be cutting out the hexagonal shape but the the last kind of part of you know milling your surface will be the result of your engraving tool paths that's based on your grasshopper curves so you don't have to use this method that we went over today this is just one possibility I did want to introduce the graph mapper because that's it's a useful tool for kind of adding some variation to your data another component that operates similarly let's see does this know that just shuffles a list of values I mean this could be used like you could just shuffle the list of Z values but that would only be like this is pretty random and if your Z range is pretty significant and you could end up with some like really odd like up-and-down type shapes that that don't really fit your surface so but this this jitter component just reshuffles a list of values it doesn't it doesn't change any values it just changes the order of the values in the list randomly so that can be useful for certain things next time we'll talk about like projecting geometry how that could be useful we'll talk about see what are some of the others here how we could use other geometry to intersect it to get new geometry yeah there any number of different ways that we can go about generating curves on the surface and ultimately that's the goal is to generate something on the surface and then bury it in relation to that surface maybe that means that they're all just slightly moved down in the Z value or something like that but then then you'll have to pass that actually start to modify your surface
Info
Channel: Daniel Eisinger
Views: 4,463
Rating: 5 out of 5
Keywords: Rhino, Grasshopper, Contours, Graph Mapper, remap, domains
Id: YcqH5JO_KQs
Channel Id: undefined
Length: 64min 52sec (3892 seconds)
Published: Tue Feb 27 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.