private Warning(Autodesk.Revit.DB.FailureMessage failure) { var elementIds = failure.GetFailingElements(); if (!elementIds.Any()) { return; } var doc = DocumentManager.Instance.CurrentDBDocument; var warningElements = new List <WarningElement>(); foreach (var id in elementIds) { var e = doc.GetElement(id); if (e == null) { continue; } var we = new WarningElement { Id = id.IntegerValue }; warningElements.Add(we); } Elements = warningElements; ErrorMessage = failure.GetDescriptionText(); }
/// <summary> /// This method is called by PerformanceAdviser after all elements in document /// matching the ElementFilter from GetElementFilter() are checked by ExecuteElementCheck(). /// /// This method checks to see if there are any elements (door instances, in this case) in the /// m_FlippedDoor instance member. If there are, it iterates through that list and displays /// the instance name and door tag of each item. /// </summary> /// <param name="document">The active document</param> public void FinalizeCheck(Autodesk.Revit.DB.Document document) { if (m_FlippedDoors.Count == 0) { System.Diagnostics.Debug.WriteLine("No doors were flipped. Test passed."); } else { //Pass the element IDs of the flipped doors to the revit failure reporting APIs. Autodesk.Revit.DB.FailureMessage fm = new Autodesk.Revit.DB.FailureMessage(m_doorWarningId); fm.SetFailingElements(m_FlippedDoors); Autodesk.Revit.DB.Transaction failureReportingTransaction = new Autodesk.Revit.DB.Transaction(document, "Failure reporting transaction"); failureReportingTransaction.Start(); Autodesk.Revit.DB.PerformanceAdviser.GetPerformanceAdviser().PostWarning(fm); failureReportingTransaction.Commit(); m_FlippedDoors.Clear(); } }
internal Warning(Autodesk.Revit.DB.FailureMessage failure) { InternalWarning = failure; }
/// <summary> /// This method is called by PerformanceAdviser after all elements in document /// matching the ElementFilter from GetElementFilter() are checked by ExecuteElementCheck(). /// /// This method checks to see if there are any elements (door instances, in this case) in the /// m_FlippedDoor instance member. If there are, it iterates through that list and displays /// the instance name and door tag of each item. /// </summary> /// <param name="document">The active document</param> public void FinalizeCheck(Autodesk.Revit.DB.Document document) { if (m_FlippedDoors.Count == 0) System.Diagnostics.Debug.WriteLine("No doors were flipped. Test passed."); else { //Pass the element IDs of the flipped doors to the revit failure reporting APIs. Autodesk.Revit.DB.FailureMessage fm = new Autodesk.Revit.DB.FailureMessage(m_doorWarningId); fm.SetFailingElements(m_FlippedDoors); Autodesk.Revit.DB.Transaction failureReportingTransaction = new Autodesk.Revit.DB.Transaction(document, "Failure reporting transaction"); failureReportingTransaction.Start(); document.PostFailure(fm); failureReportingTransaction.Commit(); m_FlippedDoors.Clear(); } }