IFC Export

IFC Export

The Revit API allows custom applications to override the default implementation for the IFC export process. To create a custom IFC Exporter, implement the IExporterIFC interface and register it with the ExporterIFCRegistry class.

When an IExporterIFC object is registered with Revit, it will be used both when the user invokes an export to IFC from the UI as well as from the API method Document.Export(String, String, IFCExportOptions). In both cases, if no custom IFC exporter if registered, the default Revit implementation for IFC export is used.

When invoking an IFC export from the API, IFCExportOptions can be used to set the same export options as are available to the user from the Export IFC dialog box.

ExporterIFCRegistry

The following example registers a custom IFC exporter in the OnStartup method.

Code Region: Registering a custom IFC exporter

/// <summary>
/// This class implements the method of interface IExporterIFC to perform an export to IFC.
/// It also implements the methods of interface IExternalDBApplication to register the IFC export client to Autodesk Revit.
/// </summary>
class Exporter : IExporterIFC, IExternalDBApplication
{
    public ExternalDBApplicationResult OnStartup(Autodesk.Revit.ApplicationServices.ControlledApplication application)
    {
        ExporterIFCRegistry.RegisterIFCExporter(this);
        return ExternalDBApplicationResult.Succeeded;
    }
}
Note: ExporterIFCRegistry is an application level singleton and only one IExporterIFC can be registered in a given session of Revit. Registration is on a first come/first served basis. If RegisterIFCExporter() is called when there is already an IFC exporter registered, it will throw an InvalidOperationException. You can check the journal file for the path of the DLL which was successfully registered as the IFC exporter for the session.

IExporterIFC

The interface IExporterIFC has only one method to implement, ExportIFC(). This method is invoked by Revit to perform an export to IFC. An ExporterIFC object is passed to this method as one of its parameters. ExporterIFC is the main class provided by Revit to allow implementation of an IFC export. It contains information on the options selected by the user for the export operation, as well as members used to access specific types of data needed to implement the export properly.

The Autodesk.Revit.DB.IFC namespace contains numerous IFC related API classes that can be utilized by a custom implementation of the IFC export process. For a complete sample of a custom IFC export application, see the Open Source example at http://sourceforge.net/projects/ifcexporter/.