Run External Command in Revit

After we’ve created a simple message command, we can now register the compiled dynamic-link library file (.dll) into Revit program.

For doing that, we have to create an add-in file.

An add-in file is a .xml file telling Revit where to load the external command or external application. In our case, a simple message, it’s an external command. First of all, a declaration of the add-in file in xml format for “RevitAddIns” tag:

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">

Second, where the assembly(.dll file), which we have compiled, is, and to which this add-in is linked. For the convenience of debugging, I’d directly point this add-in file to the one .dll which is in the debug directory, re-built from Visual Studio program.

<Assembly>C:\Google Drive\995_tailoryourbim\TYB\Level01\bin\Debug\Level01.dll</Assembly>

Two important features as the following code are the FullClassName and AddInId tags. The former can be found by hovering your mouse cursor over the line in Visual Studio where type/class is declared and it is usually formed as “namespace.classname”. As to the later one, “AddInId”, it can be online generated, and each add-in file pointing to your Revit program, the assembly, must have a unique id number.

<FullClassName>tailoryourbim.Level01.ASimpleMessage</FullClassName>
<AddInId>04a6882f-6d70-408b-b9bb-c7391c733a5f</AddInId>

And then, a few essential attribute tags describing the command and the .dll file to register. More information about the add-in tags can be found by following the registration link above.

<Text>Level01: Revit Returns A Simple Message</Text>
<VendorId>TYB</VendorId>
<VendorDescription>tailoryourbim.com</VendorDescription>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<Discipline>Any</Discipline>

Finally, the tail tags for closing up the xml file.

</AddIn>
</RevitAddIns>

Now save this file to the add-in folder, which usually is located at:
C:\Users\UserName\AppData\Roaming\Autodesk\Revit\Addins\2017

After the file is copying into this folder, if your Revit is running, a dialog window will pop-up asking if the add-in is to load, if not, start Revit and the pop-up will show up. After loading the add-in you can find the command button located in external command panel within the Add-In tab.

Published by

Ching-Hua Chen / 陳景華

The logic behind coding structures will be unveiled during step by step practices. A strong background from computer science is not what I have. I’m just an enthusiast of programming, especially in fields of geometry and architecture. Currently I work for an office in Vienna on a BIM project and I write codes in F# and Python, if needed, for the project, but mostly for my own interest.

3 thoughts on “Run External Command in Revit”

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.