Revit 2018 Export Warnings from Model to Excel

Revit 2018 has added a great new addition to the API that allows you to collect all of the Warnings that exist in the model. Previously, you could only export this list by using the builtin “Export” button in the Warnings dialog, that exported to a HTML file.

The new addition is the following:

IList<FailureMessage> warnings = doc.GetWarnings();

The following macro will export all the warnings in your model to Excel:

public void ExportWarningsToExcel()
{
// make sure to add a reference to Excel Object Library
// put the following (minus the // into your using statements)
// using xls = Microsoft.Office.Interop.Excel;
// using System.Reflection;

// create a new Excel connection
xls.Application xlApp = new xls.Application();

// make sure you have access to Excel
if (null == xlApp)
{
TaskDialog.Show("Error", "Failed to start or access Excel");

return;
}

// get the current model
Document doc = this.ActiveUIDocument.Document;

// get a list of all the model's warnings
...

Read more