Join Ian Siegel for an in-depth discussion in this video Using the List@Level feature, part of Dynamo 1.x Essential Training.
- [Instructor] In the previous video, we used the list map node to access the specific level of a nested list that we wanted to run a nodes function on. As we saw, the list map workflow is a little bit confusing at first and takes some practice but fortunately Dynamo version 1.2 introduced a new feature that makes things much easier called List at Level. On the screen right now you can see the same Dynamo script that we had open at the beginning of the previous video but right now I'm running a version of Dynamo that includes that List at Level feature.
Just like in the last video, let's set out to retrieve the description of every shelf type which we can find at index one of each sub list in our nested list. Once again, I'll drop in a get item at index node from the core list section of the node library and I'll also need a number input to get the item at index one.
Looking at our node preview, we see exactly what we saw in the last video. This node is returning the entire sub list that lives at index one. Now, instead of this outcome, we want the get item at index node to run one nesting level deeper than it is right now. Rather than looking at the top level and getting us index one, we want it to get index one of each sub list. Now, rather than introducing the list map node, we can use the list at level feature. If you're running a version of Dynamo 1.2 or later, you may have noticed that most of the nodes that you've placed in the workspace, have a right pointing arrow next to the nodes inputs.
If you click on that arrow, and I'm going to click on the one next to the input that's accepting our nested list of data, it reveals a menu that allows you to select a checkbox labeled Use Levels. Let's go ahead and check that box. Now we can see a spinner has appeared that reads @L2. That stands for at level two. This is how we can tell our get item at index node which level of the nested list it's taking as an input we'd like to run the function on. Right now the function is running at level two.
Let's take a look at the key at the bottom of that node's preview where we can see exactly the same kind of naming. If we follow the vertical line above where it says @L2, we can see exactly where Dynamo is stopping to run the get item at index function. Anywhere that you see a blue down pointed arrow, the get item at index node is running. So, Dynamo is taking this list of five items and then running the get item at index function to get the item at index one.
Once it's run the function, it goes back to our vertical line along @L2 and continues running down until it encounters another item when it runs the get item at index node again, so on and so forth until we've run out of items in our nested list. When you're working on your own scripts, you might need to change the list at level spinner in order to track down the right level of data. You can do that by clicking on the up or the down arrow to the right of the spinner.
I'll change this one from @L2 to @L3 just to see what we get. Now Dynamo's looking at the top level of the list again and it's returning the item at index one which is, again, the same sub list that lives at index one that we were seeing before we used this list at level feature. So, excellent. Now we're seeing all of the items that live at index one of their respective sub lists and we didn't need to think through the confusing list map workflow.
Now, this video was just to show you how the list at level feature works. In the next video, and for the rest of the videos in this chapter, you're going to see the list map workflow from the last video on your screen.
- 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