Skip to content

How to: create a new DynamoRevit Node

Keith edited this page Sep 21, 2017 · 2 revisions

DynamoRevit Nodes are nodes that are created to make use of powerful API on client-side like Revit. You probably have seen Revit Nodes under the library in DynamoRevit and wondering how could one create a new Revit node and make it appear in our next release. This page will demonstrate how to create a Revit node by using PerformanceAdviserRule as an example.

To make a new Revit node fully functional and a pleasant experience to use, you will need a few parts:

  • Node logic (for zero touch nodes)
  • Node UI definition (for UI nodes)
  • Node Layout Specification (2.0)
  • Node unit test

Node Logic

Node logic defines what kind of information the node contains or displays and what does the node do when Dynamo execute such node in graph. For example, performance adviser rule can be found here

Node UI

Node UI defines how the node implements user interactions. There are nodes with only input/output ports, but nodes can have dropdown, buttons, etc. as well. For example, Performance Adviser Rules node is a dropdown node. It list out all the performance adviser rules in the current Revit host document for you to select one. Based on that, you can hook up execute or Name in same sub-category so serve your own purpose. Its UI is defined here

Node Layout Specification

This defines where this newly added node will live in the brand new library implementation. You can find the Layout Specification file here which is a giant json object defining the Revit Node category under default one. This category will be read and appended to the main Dynamo library root after DynamoForRevit launched. Searching for PerformanceAdviserRule, you will get a rough idea about the object hierarchy which would be the hierarchy of Revit Node category itself. Without adding your new node to LayoutSpecs.json, the new node added might end up falling into miscellaneous category in library.

image

From the json viewer picture, you can tell

  1. PerformanceAdviserRule is a childElement under Elements which has elementType of group. This means in the library defined by this json object, PerformanceAdviserRule node will be found at Elements sub-category.
  2. PerformanceAdviserRule itself has property iconUrl which point to link of icon for it in library
  3. PerformanceAdviserRule itself has property elementType which means it is also a sub-category like Elements which is capable of holding more nodes or sub-category underneath.
  4. PerformanceAdviserRule itself has property include. This array property defines nodes inlcuded. For each array item, you need to specify namespace to class name.

e.g. for zero touch nodes

namespace Revit.Elements
{
    /// <summary>
    /// Performance Adviser Rule
    /// </summary>
    public class PerformanceAdviserRule
    {

So path for it becomes Revit.Elements.PerformanceAdviserRule

  1. PerformanceAdviserRule itself does not have property childElement like Elements do, which means there are no sub-categories under it.

You can define new sub-category under the Revit group or by extending existing sub-category depending on what nodes you added/modified. The categories are ordered alphabetically as you can see PerformanceAdviserRule falls right next to Parameter.

Node unit test

For example, performance adviser rule node tests can be found here