Friday, February 24, 2017

Export All Possible Revit Warnings

A few weeks ago, Konrad Sobon, posted a Python script for exporting all the possible Revit warnings to use in a Dynamo script that analyzes and ranks the warnings in the current model. Since I mostly work in C#, I took his Python script and created a C# macro. I've had several requests for it, so here it is...


public void ExportWarnings()
{
    try
    {
        using (StreamWriter writer = new StreamWriter(@"C:\temp\warnings.txt"))
        {
            FailureDefinitionRegistry failures = Autodesk.Revit.ApplicationServices.Application.GetFailureDefinitionRegistry();
            IList<FailureDefinitionAccessor> failuresList = failures.ListAllFailureDefinitions();
            
            foreach (FailureDefinitionAccessor failure in failuresList)
            {
                if (failure.GetSeverity() == FailureSeverity.Warning)
                    writer.WriteLine(failure.GetDescriptionText());
            }
            
            writer.Close();
        }
    }
    catch
    {
        
    }
    
}


And the resulting file from Revit 2017 : Warnings.txt

3 comments:

  1. This is great! Is it possible to actual automatically export model warnings from a model with macro or python?

    ReplyDelete
    Replies
    1. Watch for a blog post soon... *wink wink*

      Delete
    2. New post about how to extract Warnings from Revit 2018 is up: http://revitcoaster.blogspot.com/2017/04/revit-2018-export-warnings-from-model.html

      Note, this only works in Revit 2018.

      Delete