Happy Friday and Happy New Year! I hope you all enjoyed the holidays and found some time to relax. We filled our days with puzzles, boardgames, and walks which was a great way to unwind. I knew there would come a time when the packages for Dynamo wouldn’t have exactly the tools I needed and I would dive into the work of custom dynamo nodes. Currently, I have a few scripts that I would like to make more user-friendly by filtering the dropdown menu to very specific items. As I was trying to put together a custom dropdown menu, I spent a lot of time looking through existing resources and although all the information is out there, I thought I would compile everything in one place to make it easier to reference.
Zero Touch Nodes (ZTN) are custom Dynamo nodes that are written in C#, compiled, and then used inside Dynamo by importing the DLL. If you have never created a Zero Touch Node, I would recommend Thomas Mahon’s excellent course “Become a Dynamo Zero Touch C# Node Developer in 75 Minutes”. It clearly walks through how to set up your project in Visual Studio and how to create your first node as well as covering some C# basics, dynamo node development basics, and more. This walkthrough did not have information on all the references we need to import into our project because they weren’t required for the tutorial, but we do need some for the node we are making so I will review these later in this post.
As Thomas explains, public methods appear as Dynamo nodes. Node naming is taken from the DLL, namespace, and class names which can be inconvenient. One helpful piece of information I learned through this process is that you can use attributes, some people refer to them as class decorators, which allow you to override the node name, category, description, and other information so that Dynamo doesn’t pull the naming from the DLL, namespace and class names Thomas describes. Based on the information I found, you can only use the attributes on a class so each node you create will need to be a new class. You will need some of the references mentioned below to use them.
Konrad Sobon posted excellent information in response to a question on the Dynamo forum that got me on the right track for creating a custom dropdown node. We will be using the RevitDropDownBase class that Konrad mentioned to create our menu. First though, we need to track down and import the following references into our C# project. I was working with Revit 2019 but these should also be available in the later Dynamo and Revit folders.
These are all the references we need in order to use the RevitDropDownBase class and others along with the attributes. Now that we have set up our project and imported the required references, we can create our custom node, which I will walk through next week.