A Bit of Terminology

A reader was having difficulty compiling source code from a previous post, so I thought I’d post on some basics to explain a few terms and requirements about Revit macros:

A macro is an individual command that can be run in Revit. Here is the source and output from the simplest macro


module is a collection of macros. To create a macro you must first create a module that will contain the macro. The macros in a module do not need to have any functional relationship. They can do completely different things and do not need to interact with each other in any way. You can put 1 macro in each module or 100 macros in each module. If you want to create utility functions (maybe to convert feet to meters or radians to degrees) then those functions need to be in the same module as the macros that use them. Here are a few restrictions:

  1. You cannot have two macros in the same module with the same name
  2. All macros in the same module must compile without errors for you to run any of the macros in that module
  3. Each module opens in its own session of SharpDevelop


Module_Startup and Module_Shutdown are special pieces of code that are automatically created by Revit when you create a new module. Their purpose is to give you a way to automatically run code when Revit starts and just before Revit exits.  Module_Startup code is also executed every time you compile the module. By default they are empty and have no code that they run, and in most cases this is fine.

Each module must have one and only one instance of Module_Startup and Module_Shutdown. If you delete them you will get errors like:

The name 'Module_Startup' does not exist in the current context

If you have them more than once (or any other macro more than once) you will get errors like:

Type 'BoostYourBIM1.ThisApplication' already defines a member called 'Module_Startup' with the same parameter types

When a sample on this blog requires Module_Startup code (like https://boostyourbim.wordpress.com/2013/02/14/set-adaptive-component-parameter-values-with-placement-point-coordinates/where it is used to register Dynamic Model Update triggers) I will include the startup code in the blog post. You can copy that startup code into your existing startup method, or replace your existing startup method with this new one. But if you paste the new Module_Startup code and leave your existing Module_Startup code that will cause the error that there is already a Module_Startup in that module.

3 thoughts on “A Bit of Terminology

  1. Hi Harry,

    Good idea and good job to do a Revit Programming 101 course.

    It will certainly help a lot of people trying to learn by themselves from blogs and forums.

    Thanks and keep up the good work,


  2. Hi Harry, thanks for letting us know there should be only one module_startup and one module_shutdown.
    However, does module_startup have to be at the beginning of the code and module_shutdown be at the end of the code?
    Or can they exist anywhere in any order?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s