/// <summary> /// Retrieves the elements that are failing for that warning instance. /// </summary> /// <param name="warning">The warning to get the failing elements for.</param> /// <returns name="failingElements">All of the failing elements for that specific warning.</returns> public static List <global::Revit.Elements.Element> FailingElements(FailureMessage warning) { Document doc = DocumentManager.Instance.CurrentDBDocument; List <global::Revit.Elements.Element> failingElements = warning.GetFailingElements().Select(x => doc.GetElement(x).ToDSType(true)).ToList(); //unfortunately this is not cross language compatible that I know of. :( if (warning.GetDescriptionText().Contains("slightly off axis") && failingElements.Count.Equals(1)) { //we land here because for some reason Revit 2019 occasionally has issues retrieving the host too var modelLine = failingElements.First(e => e.InternalElement is ModelLine).InternalElement as ModelLine; var intersecting = new FilteredElementCollector(doc).WhereElementIsNotElementType().WherePasses(SketchFilter()).ToList(); var host = intersecting.First(e => e.GetDependentElements(new ElementClassFilter(typeof(CurveElement))).Contains(modelLine.Id)); failingElements.Add(host.ToDSType(true)); } // grab the additional elements as well. failingElements.AddRange(warning.GetAdditionalElements().Select(x => doc.GetElement(x).ToDSType(true))); return(failingElements.Distinct().ToList()); }
/// <summary> /// Provides the full description of the warning. /// </summary> /// <param name="warning">The warning to get the description of.</param> /// <returns name="description">The description.</returns> public static string Description(FailureMessage warning) { return(warning.GetDescriptionText()); }