lisa-marie mueller

lisa-marie mueller

bullet pont

custom dropdown menu (part 2) link

January 15, 2021

ipad with title, clouds, neon letters - in purple Happy Friday! Last week, we set up our project to write a Zero Touch Node for Dynamo so that this week, we can start creating some custom dropdown nodes. I did update last week's post to include two additional DLL files you will need to reference: ProtoCore.dll and NewtonSoft.Json.dll. For this example, I will walk through two different dropdown menus. They both use FilteredElementCollectors to get the elements we need for our menu. You can of course completely customize the nodes to fit your needs.

area plans

The first node we want to put together is a dropdown that only displays the different area plans in the project. We can create our class and call it AreaPlans. We want to add the attributes we discussed last week so that it is easier to control how everything is labeled in Dynamo.

First, we need to write our constructor. Then, we can use the PopulateItemsCore method, however we want to override it’s functionality so that we can populate it with our own items. The method we are overriding is protected, so our method will also be protected, it will return a SelectionState and the method name stays the same.

To use a filtered element collector, we need the active document, which we can assign to a variable called doc. Using Revit LookUp we can see that Area Plans are ViewPlans where the ViewType is AreaPlan. This allows us to easily set up a filtered element collector for our AreaPlans.

After we collect all of our area plans, if no elements were collected, we want to return null with the message “No area plans” available. If elements were collected, we want to sort them based on the Title property. This allows them to appear in alphabetical order by Title in our drop down. We also need to return our SelectionState.

Then we need to build our output. We are going to override the BuildOutputAst method. If it does not have an Area Plan to output, we want to return null. Otherwise, it will select the Area Plan from the drop down and return the ElementId as an integer.

custom area plan dropdown menu node on Dynamo canvas

title blocks

To create a dropdown just for title blocks works almost exactly the same way. We want to create a new class and can update the attributes. Since we want to specifically get all the types of title blocks in the project, not a list of the placed title blocks, we want to look for FamilySymbol not FamilyInstance. Title block families have “Title Blocks” as the name of their Category parameter so we can use this to filter for all the required families. This time, we want to sort by the element’s name and also use the name to display in the dropdown list, but return the title block family element.

summary

And in just a few simple steps, we can create a large variety of custom dropdown nodes to use in Dynamo. This can help to simplify selections in your scripts and make them faster and easier to use. Don’t forget, the DLL for your custom nodes will need to be located on the computer of everyone who needs to use the script, just like packages. Happy customizing!

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