Using the Revit IFC Export in your own add-on

In September 2011, Autodesk make accessible the Industry Foundation Classes (IFC) exporter for Revit as open source code, licensed through a LGPL v. 2.1 licensing agreement. In 2014, this project evolved to include IFC import as well, and was named “IFC for Revit”.

This source code is available on Source Forge, and everyone can contribute to the part of Revit that deal with IFC.

This source code is now the built-in IFC engine for Revit, and I was told that this engine is also behind the conversion service available through Forge.

When the user clicks on Export to IFC, an even is triggered, and Revit catch this even to run the IFC exporter. This also works when the event is triggered by the Document.Export() used through the Revit API by a third-party add-on, like the one I built last week. This IFC Export engine will then read the Revit model, convert every element into its IFC counterpart, and write the resulting IFC file.

How Revit export to IFC

This IFC engine comes with a special UI, the IFCExporterUI, designed to tap into the capabilities of the open-source IFC exporter to give you more control over the configuration of your export.

There are different add-ons for each Revit version, and each new release of Revit is shipped with the most up-to-date IFC engine available at the time. However, the code for this engine evolve quickly, and you can always download the latest version as an add-on on the Autodesk App Store.

At the time of writing, the landscape looks like this:

Revit Version Built-in IFC Exporter version Latest IFC Exporter version (with the Revit IFC add-on)
2016 Exporter 16.0.490.0 – Default UI Exporter – Alternate UI
2017 Exporter 17.0.1081.0 – Alternate UI Exporter – Alternate UI
2018 Exporter – Alternate UI Exporter – Alternate UI

If you want to know witch version you have, you can check it by opening an IFC file with a text editor and look among the first lines, the FILE_NAME one:

Check you exporter version

I didn’t dig into the subtleties of the different flavors of each Revit version, like R2 and other exotic name, you get the picture.

Last week, I published a Revit add-on to send a model to bimsync. Under the hood, this add-on exports the Revit model to IFC before uploading it to bimsync. As I was building my add-on, I realized that I couldn’t just use the Document.Export() function with whatever IFC export settings Revit could provide me. To be useful, such an add-on must allow the user to set up his own IFC Export configuration.

I look into the code of the IFC Exporter UI to understand how this user interface communicate with the export engine. I found out that you need an IFCExportConfiguration class to use a specific IFC Export configuration. Below is an example of the code needed to export a Revit model to IFC:

//Create an instance of IFCExportOptions
IFCExportOptions IFCOptions = new IFCExportOptions();

//Get an instance of IFCExportConfiguration
IFCExportConfiguration selectedConfig = modelSelection.Configuration;

//Get the current view Id, or -1 if you want to export the entire model
ElementId activeViewId = GenerateActiveViewIdFromDocument(doc);
selectedConfig.ActiveViewId = 
        selectedConfig.UseActiveViewGeometry ? activeViewId.IntegerValue : -1;

//Update the IFCExportOptions
selectedConfig.UpdateOptions(IFCOptions, activeViewId);

string folder = "A path to a folder where you want to save your IFC file";
string name = "the name of your IFC file";

//Export the model to IFC
doc.Export(folder, name, IFCOptions);

You start by creating an instance of the IFCExportOptions found in the Autodesk.Revit.DB namespace. This is standard in all Revit flavors.

Then, you retrieve or create an instance of the IFCExportConfiguration class. This is a class provided by the IFC Export add-on that hold every aspect of your export configuration, from knowing if you want to export the BaseQuanties to the path to the IfcPropertySets mapping files.

You get the Id of the active view and use the UpdateOptions method of IFCExportConfiguration to pass it along with all other properties to the IFCExportOptions.

The IFC Export add-on also provide an IFCExportConfigurationsMap class to get the built-in configurations and store the new ones.

The existing export setups

But where find these IFCExportConfiguration and IFCExportConfigurationMaps classes ?

If the IFC for Revit add-on is installed, you can find these classes in the IFCExporterUIOverride.dll. This dll can be found in your ApplicationPlugins folder, in the IFC plugin install folder (C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2018.bundle\Contents\2018)

Running this on a Revit equipped with the add-on will work nicely, but it will fail miserably when the user doesn’t have the IFC for Revit add-on. In this case, the add-on can’t find the IFCExporterUIOverride.dll containing the IFCExportConfiguration class:

Using IFCExportConfiguration without the add-on

If you have a Revit version with the IFC Exporter UI built in (Revit 2017 or 2018), the IFCExportConfiguration and IFCExportConfigurationMaps classes can be found in the IFCExportUI.dll, located in your Revit installation folder (C:\Program Files\Autodesk\Revit 2018\AddIns\IFCExporterUI). In this case, the features available are the same than our previous case, but are in a different dll.

If you don’t have the IFC Exporter UI at all (Revit 2016 and earlier versions), you must fall back to the basic export options.

In a nutshell, we have to manage these three cases:

Class DLL Revit version
IFCExportConfiguration IFCExporterUIOverride.dll

In C:\ProgramData\Autodesk\ ApplicationPlugins\IFC 2018.bundle\Contents\2018

All Revit version equipped with the IFC for Revit add-on
IFCExportConfiguration IFCExportUI.dll

In C:\Program Files\Autodesk\Revit 2018\AddIns\IFCExporterUI

Revit 2017 and 2018 without the IFC for Revit add-on
IFCExportOptions RevitAPI.dll

In C:\Program Files\Autodesk\Revit 2018

Revit 2016 and earlier without the IFC for Revit add-on

To manage these different cases, I created my own export configuration class, named IFCExportConfigurationCustom. This class handle the configuration of the export and is an interface between my code and the possible IFC export options.

I load in my Visual Studio solution the two dll containing the IFCExportConfiguration class, and using alias, I call a different version of it depending on the installation of the user:


I also handle the vanilla Revit 2016 in my IFCExportConfigurationCustom class, without using any version of the IFCExportConfiguration (which is not available in this version of Revit), using instead the plain old IFCExportOptions built-in into Revit.

By managing the different possibilities of the Revit installation, I am able to make use of the best configuration available to export IFC. I am also able to use directly the Setup configuration interface available in the custom UI, and retrieve these user-defined export setups in my add-on.

Edit IFC Export Setup

If you plan on building your own Revit add-on to upload IFC models to a cloud service, don’t hesitate to look into the source code behind this article, the solution can be found on Github.

By opening the source code of its IFC engine, Autodesk make an underrated effort toward interoperability. Even if it’s obviously not for every Revit user, I think that everyone who rely on the Revit IFC export for its own software should look at this engine to get a full understanding of the possibilities offered by this exporter


Revit and bimsync Just Got a Room Together!

This is no mystery that I am a big fan of bimsync. But the lack of integration with Revit make things a bit too time consuming than it should be. To start solving this issue, I created a small Revit plugin to upload your model to bimsync in a single click.

You must first log into your bimsync account. After clicking on login, a browser session will open, and bimsync will ask for your credentials and if you want to allow the Revit plugin to be connected to your account. This will grant the plugin access rights to your bimsync account.

Login into your bimsync account

Login into your bimsync account

Once connected, your credential will be safely stored on your computer so you won’t have to login the next time you open Revit.

You can now upload model to your bimsync account. Select “Upload”, select your bimsync project and model, type in the associated comment, select the IFC settings and click on “Upload”. After a while, depending on your file size, your Revit model will be uploaded to bimsync.

Upload your model to bimsync

Upload your model to bimsync

The Setup drop down allows you to select the IFC Export configuration. You can choose a standard “bimsync” recommended setup, an existing setup, or create a new one.

After the first export, bimsync project and model ids will be saved in your Revit model, so you won’t have to select them again the next time. If you are curious, you can find these ids in your Project Information:

Your Project information

Your Project information

To create your own IFC Export setup, you can use the usual IFC Setup Dialog. Select File -> Export -> IFC to open the “Export IFC” dialog. Select “Modify Setup” to open the “Modify Setup” windows, and click on “New” to create a new configuration. You can now set everything in this new configuration before selecting OK to close the “Modify Setup” windows. You can now safely close the IFC Export dialog without exporting anything, and open again the Upload dialog in the bimsync plugin. Your new configuration will be available in the drop-down.

Edit IFC Export Setup

Edit IFC Export Setup

You can also go directly to your bimsync account from Revit by clicking on “Profile”. This is not very useful, but at least you will be a few clicks nearer to change your profile picture.

Under the hood, the system is quite simple. The plugin will look at your selected IFC Setup and use them to export your Revit model in an IFC file. This file is then zipped and uploaded to bimsync.

Between exporting to IFC, compressing the file and uploading it to bimsync, the entire process can be rather long. Depending on your model size, computing power and Internet bandwidth, the Upload command can take a few minutes to complete. I am thinking on using the Autodesk service Forge to convert Revit model to IFC online, freeing your computer from this tedious task.

You can already download the plugin on the Autodesk App Store.

As usual, the entire source code is available on Github, feel free to use it on your own project. Don’t hesitate to report on any issue you might have with this plugin, there is always a lot of room for improvement.