In this example we will be using the RevitAPIUI.dll and calling the Revit TaskDialog window to show the user a custom message in Revit.

Most programming tutorials start with a “Hello World” example, this has supposedely been around since 1974 and was first coined by Brian Kernigham in the memorandum Programming in C: A Tutorial…so I feel I should really follow suit to keep tradition although I have made a little alteration.

Naturally, we’ll start by creating a fresh instance of the Python Node. But we will also add a few extra things off the bat as we will need them. (Note: I always put a Code Block for my inputs to naked python nodes – naked meaning it is editable in the main graph space and not yet a custom node)


In the Python Node you will need to clean it up and Reference the “RevitAPIUI.dll”. If you are unsure what referencing is or how to do it then go back and look at this post. (Or you can wing it and continue on). Your code should look like this after you have made the changes…

 import clr
 #add a reference to the Revit UI .dll so we can access the UI Namespace...
 #import everything from the UI Namespace...
 from Autodesk.Revit.UI import *

We then need to add our Inputs to variables so we can use them in our code…

 #IN Variables...
 enabled = IN[0]
 msg = IN[1]

Now we can use these in our next bit of code to control when we can show a message in Revit and what message will be shown…

#check if enabled is True, if it is then show message...
 if enabled:
     #show the message dialog box...
     TaskDialog.Show("From Python With Love", msg)
     #return a result in Dynamo...
     OUT = "Got the message"
     #return a result in Dynamo...
     OUT = "Enabled needs to be set to True to run"

I have not gone to the extremes of checking the variables types before using them (although, as a good programmer you really should so someone doesn’t plug in a string where it should be a bool). We’ll be lazy this time! 🙂

Now, if you run this code you’ll see that you will get a Pop-Up dialog box appear in Revit that looks like the image below…Neat eh?!?


You will notice that the TaskDialog pauses Revit and Dynamo while it is showing. This is because it is a Modal Dialog that requires User interaction before the applications can continue. A very useful feature.

Now, there are ways you can expand on this further as you can add more buttons e.g Ok, Cancel, Abort, Retry. Have a think about how you can make this useful in your workflow? Here are some ways I use this:-

  • Let the User know there is an error
  • Allow User to cancel a long operation before it starts
  • Allow User to cancel Elements being modified or deleted

There are probably loads of other ways you could use it too. Go experiment!

For more advanced features have a look and see if I have written any in Worked Examples-UI.