lisa-marie mueller

lisa-marie mueller

bullet pont

managing data types (python for Dynamo) link

December 18, 2020

laptop with title, cloud shaped balloons, rocket shaped balloon, yellow and purple Happy Friday! I hope you all enjoyed AU this year and had a great time during the recent holidays. I know for my husband and I, it was nice to have a very small gathering with just our immediate family for Thanksgiving. We also got to do a lot of hiking, which we loved! I can’t believe it’s all gone by so fast and we are now past mid-December.

If you want to start learning how to code, python is a popular choice with a wide variety of applications. For example, you can use it for custom nodes in Dynamo. A great stepping stone is to start turning pieces of your graph into python nodes. I frequently do this with filtering as mentioned in a previous post, especially for parameters, because it speeds up the process. It can also be used to efficiently get the data type you need.

data types

I noticed there were a couple tasks that I always use Python nodes for and I decided to share another one. For this graph, I am taking the phase created and phase demolished parameters and copying the name of the phase as a string into a custom parameter. I need to write this phase as text to a text parameter so I can use it for a filter in a view template.

I find that I frequently need to change and manage the data type of outputs from various Dynamo nodes. For example, when you get the phase of an element using the Element.Phases node, it returns an object representing the phase element. In order to copy this to a string, we need the name, but we also need to handle the cases for when the phase is none. To accomplish this, we can add a couple lines of code in a python node.

Our IN will be a list of the phases. In this case, phase demolished. We will also need a new empty list to store the text in. Then we look at each phase in the phaseDemolished list. If it is equal to none, we add the text “none” to our phaseDemolishedText list. Otherwise, we get the name of the phase as a string and put that into our list. Then we can output our phaseDemolishedText list and the node will return a list of strings noting either the phase name or “none” based on the conditions.

Then we can use that in our graph to copy both the Phase Created and Phase Demolished parameters to a text parameter. And this is what the graph looks like in use:

dynamo graph with collect elements with parameter node and filter list based on parameter value node


Thank you for all the support this year. I can say it has certainly been strange. There are so many things that have not gone right, but there are also things I am grateful for, like getting to spend more time with my family. I will not be posting over the next two weeks, but will be back to a more regular schedule in January. I wish you happy holidays and all the best for the new year.


If you want to learn to code and don’t know where to start check out my posts about Steps to Learn to Code [for architects and designers] Part 1 and Part 2.

Revit API Docs

bullet pont

recommended next