From the course: Dynamo for Revit: Python Scripting

Unlock the full course today

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

Saving our own module

Saving our own module

From the course: Dynamo for Revit: Python Scripting

Start my 1-month free trial

Saving our own module

- [Voiceover] Just as we can import and utilize modules from python files, we can also save our own python modules and import them into different scripts. So in this video let's have a look at how we can do that. I currently have the Dynamo exercise file open for this video. In here you'll find a python script. And as you can see, I've already defined a function name, ThreeMultis, which 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. This checks if the first parameter is the same object type as the second parameter, and if so returns true. This makes the function safe, so it's not trying to operate on a non-list item. If it is a list, a loop will iterate through each of the list of numbers, and appends any number that is modulus three and not zero. And then after the loop ends, it will return this list of numbers. So say we wanted to save this function to reuse…

Contents