What is up with trying to do everything in python not nodes?

This isn’t a criticism, I’ve just noticed that there have been a ton posts where people are asking specifically how to do thing in Python not by node. What is driving this trend?

I was speaking with an interviewer and he mentioned that he prefers his employees to not use packages so the scripts can be shared around without dependencies. But that can’t be everyone’s reasoning.

Do you know whats going on? did I skip a AD university talk or something?

There are many reasons but I’ll try to give my explanation for the common ones.

Dependencies - You already mentioned this but it can be very important when sharing graphs with more than a few people. It also means you don’t have to maintain package versions at all.

Availability - In many cases when dealing with another API, like Revit, there may not be a common package or custom node that does what you’re looking for. Even those common functions that do have available custom nodes, they may not be written for your specific use case or intention. Python can quickly become a necessity when dealing directly with the API.

Speed - Python will typically execute much faster than using Dynamo nodes. Part of this is due to Dynamo executing and maintaining node outputs individually. Using DesignScript within a codeblock can help, but again, dealing with the API or core code directly will usually be faster than something within a wrapper. All that being said, this is really only an issue with larger or more complex datasets.

Comfort - For some people it just comes down to comfort. Those with previous coding experience may find it faster and more efficient to write in Python directly. Even those who end up learning Python with Dynamo often find that most scenarios dealing with complex list structures, looping, or higher level functions are easier to handle within Python.

I’m sure there are plenty more but those are the top few to come to my head at this moment. To put it simply, once users get comfortable with Python it tends to be a more efficient use of time.


edited to add the section on dependencies and ease of use
Some clarity on a few points

Dependencies: The management of packages being more difficult than the management of Python code inside a DYF is a common misconception. Soon as those BIM managers have to hunt down all the graphs in the office, do a ‘save as’ for the 2022 graphs and manually edit each bit of Python to change the units from the old Revit units into the ForgeTypeId units the difficulty becomes clear. Edit once and deploy like it was an XRef is easier than editing every use of the code base.

Speed: Well written Python which removes marshaling and serialization from the Revit environment to the Dynamo environment is usually faster once you sequence your code to allow the multiple loops as a functional series with managed memory allocation. I did a live demo illustrating. The speed of the various methods when staying in the Dynamo environment in a community conversation last year - the demo starts around the 40 minute mark of ‘How to Make Dynamo Sing’: 20 - How to Make Dynamo Sing! - YouTube

Lastly, one of my own: Writing a graph with nodes is fairly easy - there are a set number of permutations you can come across. But writing code in Python with limited access to examples in the language gets a bit tougher. As an example: If you only had Dynamo and you wanted to make a directshape, it’s pretty straight forward: Find the Room.ByPoint node, and search for the inputs to get you there - it’s almost trivial for some operations. But if you wanted to get to the same result using the Revit API, you quickly learn to appreciate the simplicity of visual programming, as the things we take for granted quickly become things we need to learn.


In addition to what people said, I encourage users in year 2 of their journey (or thereabouts) to explore it as it forms a natural segway into learning about other options like pyRevit or C# which go well beyond Dynamo’s capabilities.

When using Python in Dynamo I still try to package most of what I use up into my own custom package rather than leave blocks of Python all over the canvas though.


Thanks for all the answers.

I only use Python as last resort. Either a specific API call isn’t in a common package or if I want to do something imperative. I suppose there are also Python libraries that are exposed to Dynamo for specific tasks and analysis.

Everyone gave me some good ideas. I’ll try to think of good ways to integrate Python in to my workflow more.

1 Like

For me I use Python as it’ll do stuff Dynamo can’t.

Also, even if Dynamo can it’s interesting and useful to learn how to do it in Python as you learn more that way.

1 Like