In this video, we begin with the lists of numbers that were produced in the previous video by the List.Create, Number Sequence, and Number Range nodes, and explore how Dynamo tends to perform familiar functions (Addition, Less Than, Point.ByCoordinates) respond to inputs that contain lists of numbers rather than a single value.
- [Voiceover] Now the ListCreate node is just one method of constructing a list in Dynamo. Let's take a look at two functions that can be used to generate a list of numbers rather than specifying numbers and adding them to the list one at a time. If we head back over to the core list section of the node library, let's drop in a sequence and a range node. To keep our graph from getting too messy, I'm gonna drag the sequence and the range nodes down just a little bit. Now, both the sequence and the range nodes take three numbers as inputs. Let's go ahead and plug in all three of our integer sliders into the sequence and the range inputs, and we'll compare what comes out on the other end.
I'm also going to drag our integer sliders down to get them closer to the inputs we're about to plug in. I'm gonna plug the five into both of the start inputs. I'm gonna plug then ten into both the amount and the end inputs, and that's gonna be a major factor in how these two nodes behave differently. And we'll plug the number one into the step input of both. Now, let's take a look at the node previews. We'll pin them both down and let's line them up next to each other so we can compare easily.
Notice that the sequence node outputs 10 numbers - remember we start counting at zero now - while the range outputs six. Both lists start at the number five, which is what the start node means. That makes sense. And both lists increment by the number one, which we set up in the step input. Now the key difference here is how each node handles the number 10 that we provided as the second input. See that the sequence node generates a list that's exactly 10 items long whereas the range node just keeps counting until it reaches the number 10 and then it stops.
Let's change the step input to two instead of one, and we'll see how both lists are affected. Now you can see that both lists are counting by two. The sequence node still returns 10 items as it did before, but now the range node only counts up to the number nine and it stops. It doesn't exceed 10. We're also seeing a couple fewer items in the range output because when we're counting by two, there are just fewer numbers between the numbers five and 10. So now that we've produced a list of numbers, let's see how these function nodes respond when we plug them into some of the nodes that we've seen in a previous example.
Let's begin with the addition node, which we can find in the operators section of the node library. From here on out, let's just use the sequence node as our input. I'm gonna move the range node out of the way. Looks like I also need to re-pin our sequence preview. I'm also going to drop in a new number input node. We can find that under core input, and then we'll select number, and then we'll the number node.
Let's see what happens when we plug the sequence output into our addition node as well as say the number eight. When we take a look at the node preview coming out of the addition node, we have another list of numbers. It's the same length as the X input here, our sequence list, and if you compare index zero on both of these lists, we'll see five is coming out of the sequence, and we'll see 13 is index zero out of the addition node, which is five plus eight equals 13.
If we go down one more, index one is seven and 15. Seven plus eight is 15, nine plus eight is 17. So what's actually happening here is each item within that sequence node is being added to the number eight, and that's what's coming out of our addition node. In other words, each item in the list that's being plugged into X is being added to eight, which is plugged into Y. Now, let's try running the same list through the less than node, which we can find in the operator section of the node library.
The less than node also takes an X and a Y input. So let's use the sequence output as our X again, and let's reuse the number eight as our Y. Now let's take a look at our node preview again. In the same way, we have a list of 10 values, but this time, we're seeing boolean values instead of numbers. Looks like our first two values are true and the rest are false. If we compare what's happening here, we have a list of our sequence inputs, so five, seven, nine, all the way down to 23, and the less than node is asking each one of those items in the list, "Are you less than the number eight?" which is plugged into our input Y.
Five and seven, yes, they are less than the number eight so they return a value of true, but as soon as we get to index two, we see a false value. The reason being index two of the sequence node is nine. Nine is not less than eight. It's greater than. So when you ask nine if it's less than eight, the answer is false. And because these numbers are just getting bigger as the list goes on, we see false all the way down through the rest of the list. So lastly, let's drop in a PointByCoordinates node one more time, which we'll find under the geometry point section of the node library. So you'll notice that we're clearly running out of space on our canvas here.
I'm gonna go ahead and unpin some of these previews since we're finished working with those nodes. I'll also move this cluster of three nodes up a bit to make room for PointByCoordinates. So if you remember from a previous video, each of these inputs has a default value of zero, which is why a point appeared in our background preview of the origin as soon as we dropped the node onto the workspace. Let's connect the list of values coming out of that sequence component into the Z input and see what happens. Looking at the geometry preview, we can see that 10 points are now created hovering above the origin.
If we look at the node preview on the PointsByCoordinates, we'll see 10 points organized in the same way as the other lists, same as the numbers or the booleans, but here we see that each item in the list is a point. Dynamo also gives us a little bit of information about the points, specifically its X, Y, and Z coordinates. If we compare the Z coordinates of each item in the list, we'll see we have five, seven, nine, 11, down to 23, just like the sequence list that we provided as a Z input here. So we've now identified three ways to quickly build a list of numbers, and we've seen how nodes tend to process lists of multiple inputs.
They run through each item in the list one by one, perform that node's function, and then they return a list of each result in the same exact order as the input list.
- Placing and connecting Dynamo nodes
- Understanding Dynamo's data types
- Performing math functions
- Creating number lists and text strings
- Writing data to an Excel spreadsheet
- Creating points, curves, surfaces, and solids
- Analyzing geometry
- Linking a Dynamo-driven SAT into Revit
- Placing Revit families with Dynamo
- Creating Revit views and sheets with Dynamo