Saving libraries of functions you create allows you to reuse code for later projects. This simple video demonstrates how to save your work to Python files.
- [Instructor] Defining functions in Python…is ideal for situations in which we want…to reuse a piece of code more than once.…This becomes even more useful when creating…a function that can be used over multiple Dynamo files.…We can do this by means of importing…Python files known as modules.…In the exercise file you'll see…that I've already placed a Python script node.…Go ahead and open it up.…In this script you'll see that I have defined…a function named ThreeMultis.…This takes a list of numbers as the input…and returns a list of numbers from…that list which are divisible by three.…
It does this by using the built in function…isinstance on line four, which will check…if the first parameter is the object type…of the second parameter, and if so, return true.…This makes the function a little safer…so that it's not trying to operate on a non list item.…And if that statement is true a for loop…will cycle through each of the numbers…and any number that is module less three equals zero,…or zero, will be appended to the return list list.…
Note: This course uses Dynamo 1.3.1 and Revit 2018. For best results, it helps to have the same versions of the software.
- Importing the Dynamo Geometry library
- Defining variables
- Making decisions with conditionals
- Controlling flow with operators
- Defining functions
- Working with external libraries in Python
- Accessing the Revit API with Python
Skill Level Beginner
1. Dynamo and Python
2. Python Basics
3. Working with Libraries
4. Revit API
Next steps2m 18s
- 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.Cancel
Take 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.