lisa-marie mueller

lisa-marie mueller

bullet pont

custom dropdown menu (part 1) link

January 08, 2021

ipad with title, clouds, neon letters - in blue 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

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.

node naming - using attributes

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.

required references

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.

  • C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\nodes\CoreNodeModules.dll
  • C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\Revit\nodes\DSRevitNodesUI.dll
  • C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\DynamoCore.dll
  • C:\Program Files\Autodesk\Revit 2021\RevitAPI.dll
  • C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\Revit\RevitServices.dll
  • C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\ProtoCore.dll
  • C:\Program Files\Autodesk\Revit 2021\NewtonSoft.Json.dll

summary

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.

resources

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