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

2 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