From the course: Dynamo for Revit: Python Scripting

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Nested loops

Nested loops

From the course: Dynamo for Revit: Python Scripting

Start my 1-month free trial

Nested loops

- [Instructor] Now that we have a good understanding of how loops work, let's take a look at nesting the for-loop. This is basically putting one loop inside of another, which becomes useful when working with nested lists. I currently have the Dynamo exercise file open for this video. We can use this to test nested loops. To start, go ahead and place a new Python Script. And open it up. To understand how nested loops work, let's create our own nested list. Start by creating a list of numbers by using the range method and the variable lst. Let's create 10 numbers, then let's create an empty list named output which we can later append items to. Next let's create a for-loop as we've done in previous videos, using the variable X and the range of numbers lst. Within this loop, let's create a point, using X for the x-parameter. We'll name this p1. Then using this point, let's create a new cuboid, using the Cuboid.ByLengths method, and we'll name it cube. This takes a point for the first…

Contents