This video is titled Points and Lists. So in this video, I'm going to talk a little bit about dealing with points as lists, particularly when you import them. Up until this point we've been working with importing single objects, points, curves, shapes into our Python editor and working with them but if you go to the online dictionary and you typed in get, you would see that there's a plural function oftentimes where there's also a singular function. So for GetObject, which we've been using, there's also something called GetObjects. We know GetObject returns a single ID. If we go under GetObjects, we'll see that what it returns is a list. It's going to return a list of IDs of the picked objects. This is going to be true actually whether I select a single object or multiple objects. If I select a single object, it's still going to see it, it's still going to return it as a list and we'll see that structure when we print it out. We'll see the difference. There's also something else to note here, something we haven't seen under parameters. So we've been using the filtering throughout. We've been using this function called rs.filter and we've been filtering out the objects. There's also another method and this is actually an older method. I just want to point it out. It's here, we can actually use a value to filter. So instead of typing rs.filter point, we would just replace that with one. This is actually an older method before this filter function was created. There's something else I want to point out about that, but I'll just show you something here. I'm going to input some points and then I'm going to print that out. If we run this saying, select some points, I've created five points in my scene and if I'm using objects, I can just window everything and select it all at once. Hit Enter and down in my output, I'll see that it's outputting a list because I can tell to lists because it's starts with a bracket and it ends with a bracket. So it is a list and it's showing me separated by commas. It's actually telling me the data type, it's a GUID object and then it's telling me the GUID. So if I just selected one point, which I can do, I can just click on it. I don't have to window it, hit Enter, it's showing me the ID for that, but it still has it in brackets to it's still understands it as a list even though it only has one item in it. Now, I can create a list that's empty. I showed that in some of the lessons. So something can still be a list and have nothing in it. The other thing I wanted to just point out with this rs.filter point, you'll notice that there are no plural selection methods in it, unless it all objects. If I'm selecting a bunch of curves, I don't type in curves here, I just type in curve. That same goes with points, meshes, surfaces, poly surfaces. So I don't put a plural name there. I only need point. This because I'm using GetObjects, selecting a bunch of things using window to do it and it's reveals the usefulness of the function of the rs.filter point. So for example, if I had a couple other different types of objects in here, say a couple of rectangles. and I didn't want to select those because I have the filter on, I can select everything and it's only going to select the points. So that makes it really handy for selecting things. Again, I don't need to have that. I don't need to have anything here. It would still work, but that I would be mixing points and rectangles. So let's get rid of those for a second. The first question one might ask when I'm importing a bunch of things, is what order does it import the min, what is the first point within my list? There's no way from looking at this print out the list of me telling what actual order these points are in. One way to maybe a kind of rudimentary way of finding that out would be to use the delete object function. Delete, in this case, I'm going to delete the first point, the point in pointGUIDs list. That's an index number 0. So the first point within my list. So if I run this, select everything, hit Enter. Then I go back and inspect the points and I see, now this one over here is missing, and so that must have been the first point in the list. So undo this, Control Z. So there it came back. If we go back here and if I put something else in like index 2, run it again, select everything. So now I know that one over here, that was index 2. So there's probably Control Z to undo it. There's probably isn't the best way to go about finding out the organization of my points. I'm going to change this back to zero. Something else I wanted to point out is that the organization of them is based on two things. It depends on how I select them. If I'm selecting them by just windowing them, the order that they're in is actually the order that I created them in Rhino. Or, and we're going to find this later, if I was creating them within the code, the order in which I created them in the code is the order in which they're put in, in the list. Now, I could change that. So if we have our delete zero, deleting the first point in our list. If I ran this again, and I didn't use my window selection, but if I selected them individually one at a time, hit Enter. Now it eliminates the first point that I selected. So there is a way to override that in the manual selection, if you select them in a particular order, that's the order that they're going to be put in within the list. Let's Control Z that, undo that. So there's an easier way though to go about understanding where they are indexically in space, and that would be to label them. So I can use a function called, and I'll undo, uncomment this Shift Control U. Using the function TextDot. Now you've probably used, if you've used Rhino a lot, you've probably typed in the command line dot, which brings up the tool dot. Sometimes it takes a second for the dialog box to come up. Here it is. So this allows me to write anything in here in the display text, hit Okay, and then I can snap that to a point. It's not permanently stuck to that point. But I can label a point with whatever I want. Well, we can use that tool in code and we're going to be using it quite a bit because it's a really handy way of visualizing the structure of our code in Rhino space. Way of seeing its organization and Rhino space is really important points. So this is a tool that we're going to be referring to using quite a bit. So AddTextDot needs, if I look it up, it takes two parameters. It takes a text string. It does say string here, but we'll also see that I can give it numbers and it deals fine with numbers. I think it converts the numbers to a string so it's able to print it out in Rhino space, and that is looking for a point, 3D point. It will work fine with point values, but it will also work fine with an ID, with a point ID, which is what we have imported. So we'll see how that works. So I'm going to label the points in my list here that I brought in. I have five points. Again, they begin the counting in a list, the first index number 0, and I'm going to give that point a label 0, and then the next one 1, the next one 2, the next one 3. So this is extracting the point ID, the 3D point from that list. So let's run this and see what it does. I'll window all the points and now it's showing me the order in space in which I drew them. So that was the first one, that was the next one 2, 3, and then four here and again, these points are separate from the actual point, but they're just on top of that coordinate. Let's undo that, Control Z, go back to our code. I could also, if for whatever reason, I could also, if I comment this out, un-comment this next section, I could label them with the coordinates, the coordinate values of the points. So using the function RS.point coordinates and this brings up something else. I don't think I've done this before, so I can call a function within another function. Here I'm doing AddTxtdot. In the first part of it, the label, I'm going to label it, I'm finding the point coordinates of that point. So I'm nesting this function in the first part of this function so it's just going to return those values and then that's going to become the text that it's going to then render out at this point. We'll see how that works. Select the points, hit "Enter," and now I've visualized the x, y, z values of those points in space, which could be handy at some point. So we'll comment that again. Typically, I want to know the index number, I want to know the order. Typically, I'm not so concerned about the coordinate value, so I'm going to Shift Control U to un-comment that. So what can we do with these points? Well, one thing we could do is we can create lines and curves. If I wanted to just add a line between any two points, so we already know this function, what it takes is it will take an ID, point ID, 3D point. So I give it two points, and that's all it takes, just two arguments, two points, and it's going to draw a straight line from 0.0-0.4. Select everything and it shows me that right there. So another one we haven't seen, addCurve, which we'll be using a lot. Let's look it up before you use it. See what it needs. So addCurve parameters, what are its arguments? What's it looking for? Points. This is important. It needs a list of points. Well, I could give it two points. We could try that out, but I'll have to write it as a list within the function and I'll show how to do that, and then the only other thing it needs is a degree; a degree of the curve. Now, we haven't talked about nurbs too much. If you used Rhino a lot, you probably know a lot about them. The default is a three-degree curve, nurb curve. So if I'm drawing a curvy curve like this, that's a three-degree curve, and actually, if I polyline, which is a straight segmented line, it's actually a one degree nurb curve. So a one degree nurb curve has straight sections. So if I did do the curvy curve and change my degree up here in the comments to one, I'm going to get a curve with straight sections. So that's something to keep in mind when you're doing addCurve. Now, if I just leave that out, it's going to go to the degree three by default. So if we run this, and so that's going to give me curvy curve and if I click on this, we'll see its control points are at those points that I've input. If we wanted to force it to be one degree, I would put the integer one in here and that I should get a curve with straight sections. PtGUIDs, that's already a list. We know that because we printed it out. It's printed out down here, it's a list of points. Now, if I wanted to, let's say only go between certain points within that list, so I want to draw a curve from point 0-4-2, and it's going to be a one degree curve, because these are separate points that I'm selecting here, I need to put them within parentheses. So I'm actually making them a tuple. The function understands a tuple as a list oftentimes are interchangeable because we know the difference is that the list is just mutable, or the better way to say it is a tuple is immutable list, so it's still a list, it's organized like a list indexically. So I can put this in parentheses, I could also put it in brackets, but I don't need to, and so it's going to draw a curve between those. So that makes those three points a list within the function. Now it's drawing that straight line curve polyline between 0, 4, and 2. We could do that for something else. Again, it doesn't have to be in order. I'm going 0, 4-2, four or 1-4-3. They don't have to be in order that they are within the list because I'm reorganizing them here. When I put them in this new list. I forgot to undo that. Sorry. Now it's drawing from 1-4-3. Now, the other thing to point out here, too, is that even though this could be in whatever order I want it, the direction matters. So this order that I put these points in determines the direction of the curve that I create, so I'm going 0-4-2. So if I type in DIR up in the Command Line, it tells me that my direction is from 0-4-2, and the same would hold true for the other ones. So that order that you put the points in in the list is important for the direction of the curve that it creates. Oh, something else I'm not doing here is I'm not saving these curves. If I wanted to save it, I would need to give it a variable and that's going to save an ID of that new curve that we see right here. So that's the idea of that curve. One last thing in here, if I wanted to create a closed shape, my first and last points in the list needs to be the same. That makes sense if I want to make, say, a closed polyline. If you imagine how you would do it manually, I would go from 0 to one, to two, to three, and then I got to come back to zero in order to close that to make a closed shape. So it's the same encoding too. In that list, my first point zero here needs to be repeated here at the end of the list so I can close it and make a closed shape. Let's run this, select our points, and now we're drawing those two curves and that closed curve. In the next video, we're going to talk about how do we go backwards here, how do we input some curves and shapes, and get lists of points out of them.