Working with large lists of data in Python and Dynamo, there is often the need to perform a single function over every item in the list. Python offers the ability to do this by using the for loop. Jeremy demonstrates how to set up a for loop in Python by looping through every number in a list of numbers and creating Dynamo geometry for each number.
- [Instructor] While scripting with large lists in Dynamo,…we often need to perform a single function…for every item in a list.…Say, for example, we have a list of numbers.…We may want to create a list of points…based on those numbers driving the x coordinate.…To do this in Python, we need to learn about…a programming concept known as looping.…Looping allows us to execute an instruction repeatedly…until a certain condition is met.…Say we have looped, or iterated,…through every item in a list.…
There are two types of looping in Python,…the for loop and the while loop.…Let's start by looking at the for loop.…Say, for example, we had a list of numbers…zero through to five.…A for loop will allow us to loop over every item in the list…and perform an instruction.…To do this we need a variable, say var, for example.…And for each loop through the list…the item is assigned to the variable.…So looping through our list of numbers,…in the first loop var would equal zero.…
In the second loop var would equal one, and so on.…This will continue until every number in the list…
Author
Released
12/14/2018Note: This course uses Dynamo 2.0.1 and Revit 2019. For best results, it helps to have the same versions of the software.
- Importing the Dynamo Geometry library
- Python basics: variables, conditionals, operators, loops, and functions
- Using and extending Python modules
- Accessing the Revit API with Python
- Revit and Dynamo conversions
- Creating a collector in the Revit API
- Getting Revit parameters with the Revit API
- Adjusting elements with the Revit API
- Creating views with the Revit API
Skill Level Intermediate
Duration
Views
Related Courses
-
Dynamo: Practical
with Paul F. Aubin2h 51m Intermediate -
Grasshopper and Rhino: Python Scripting
with Jeremy Graham5h 12m Intermediate -
Dynamo Essential Training
with Ian Siegel3h 9m Appropriate for all -
Dynamo for Revit Project Setup
with Ian Siegel1h 35m Intermediate -
Learning Python
with Joe Marini2h 11m Beginner
-
Introduction
-
What you should know1m 31s
-
Exercise files1m 2s
-
1. Dynamo and Python
-
The Python node basics5m 5s
-
What is OOP?5m 58s
-
Importing the Dynamo library4m 31s
-
-
2. Python Basics
-
Defining variables6m 26s
-
Numbers7m 40s
-
Strings7m 11s
-
Working with lists6m 22s
-
Control with operators5m 46s
-
Logical operators7m 14s
-
Looping with the for loop5m 17s
-
Looping with the while loop6m 22s
-
Break and continue3m 15s
-
Nested loops6m 20s
-
Dictionaries6m 37s
-
Try and except3m 55s
-
Defining functions6m 7s
-
-
3. Working with Libraries
-
Built-in Python modules6m 58s
-
Extending Python modules4m 28s
-
Saving our own module5m 6s
-
Accessing Revit nodes6m 18s
-
Importing the Revit API3m 12s
-
Working with the Revit API7m 46s
-
Revit conversions5m 53s
-
Dynamo conversions6m 57s
-
Navigating the Revit API5m 49s
-
-
4. Revit API
-
Collecting elements3m 22s
-
Creating a collector7m 14s
-
Getting Revit parameters5m 51s
-
Setting Revit parameters6m 24s
-
Element locations3m 25s
-
Adjusting elements5m 13s
-
Creating a view4m 6s
-
View bounding boxes6m 23s
-
-
Conclusion
-
Next steps2m 34s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Looping with the for loop