Message 1 of 3

Not applicable
03-25-2018
02:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I'm trying to read all Revit-warning by using the following code.
public static List<string> GetRevitWarningList(Document doc, bool isEmptyList = false) { if (WarningList != null && WarningList.Count > 0 && !isEmptyList) return WarningList; WarningList = new List<string>(); FailureDefinitionRegistry failureReg = Autodesk.Revit.ApplicationServices.Application.GetFailureDefinitionRegistry(); StringBuilder sb = new StringBuilder(); Type _type = typeof(BuiltInFailures); Type[] _nested = _type.GetNestedTypes(System.Reflection.BindingFlags.Public); Dictionary<Guid, Type> _dict = new Dictionary<Guid, Type>(); string _ClassName = string.Empty; foreach (Type nt in _nested) { try { _ClassName = nt.FullName.Replace('+', '.'); sb.AppendLine(string.Format("#### {0} ####", _ClassName)); foreach (System.Reflection.PropertyInfo pInfo in nt.GetProperties()) { System.Reflection.MethodInfo mInfo = pInfo.GetGetMethod(); FailureDefinitionId res = mInfo.Invoke(nt, null) as FailureDefinitionId; if (res == null) continue; if (_dict.ContainsKey(res.Guid)) continue; _dict.Add(res.Guid, nt); FailureDefinitionAccessor _acc = failureReg.FindFailureDefinition(res); if (_acc == null) continue; sb.AppendLine(string.Format(" * {0} <{1}> {2}", _acc.GetId().Guid, _acc.GetSeverity(), _ClassName)); sb.AppendLine(string.Format(" {0}", _acc.GetDescriptionText())); WarningList.Add(_acc.GetDescriptionText()); if (_acc.GetDescriptionText().Contains("Ref Plane is slightly off axis and may cause inaccuracies")) {
// Do something, } } } catch { } } return WarningList; }
However, I'm unable to find the parent text of these warnings like it show in the Revit warning window (please see the image below). I'm wondering if there is any way to get the description-text of their parent and get the list of their child warnings in a nice hierarchical structure.
Solved! Go to Solution.