/// <summary> /// Implements the FailuresProcessing event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { FailuresAccessor failuresAccessor = e.GetFailuresAccessor(); //failuresAccessor String transactionName = failuresAccessor.GetTransactionName(); IList <FailureMessageAccessor> fmas = failuresAccessor.GetFailureMessages(); if (fmas.Count == 0) { e.SetProcessingResult(FailureProcessingResult.Continue); return; } if (transactionName.Equals("Error_FailuresProcessingEvent")) { foreach (FailureMessageAccessor fma in fmas) { FailureDefinitionId id = fma.GetFailureDefinitionId(); if (id == Command.m_idError) { failuresAccessor.ResolveFailure(fma); } } e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit); return; } e.SetProcessingResult(FailureProcessingResult.Continue); }
/// <summary> /// Implements the FailuresProcessing event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { FailuresAccessor failuresAccessor = e.GetFailuresAccessor(); //failuresAccessor String transactionName = failuresAccessor.GetTransactionName(); IList <FailureMessageAccessor> failures = failuresAccessor.GetFailureMessages(); if (failures.Count != 0) { foreach (FailureMessageAccessor f in failures) { FailureDefinitionId id = f.GetFailureDefinitionId(); if (id == BuiltInFailures.JoinElementsFailures.CannotJoinElementsError) { // only default option being choosen, not good enough! //failuresAccessor.DeleteWarning(f); failuresAccessor.ResolveFailure(f); //failuresAccessor. e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit); } return; } } }
private void ControlledApplication_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { var failList = e.GetFailuresAccessor().GetFailureMessages(); if (failList.Any()) { e.GetFailuresAccessor().DeleteAllWarnings(); e.SetProcessingResult(FailureProcessingResult.Continue); } }
private void Application_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { // Inside event handler, get all warnings var failList = e.GetFailuresAccessor().GetFailureMessages(); if (failList.Any()) { // skip all failures e.GetFailuresAccessor().DeleteAllWarnings(); e.SetProcessingResult(FailureProcessingResult.Continue); } }
void Application_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) //Errors handling { FailuresAccessor fa = e.GetFailuresAccessor(); IList <FailureMessageAccessor> failList = new List <FailureMessageAccessor>(); failList = fa.GetFailureMessages(); // Inside event handler, get all warnings foreach (FailureMessageAccessor failure in failList) { // check FailureDefinitionIds against ones that you want to dismiss, FailureDefinitionId failID = failure.GetFailureDefinitionId(); // prevent Revit from showing Unenclosed room warnings FailureDefinitionId failID = failure.GetFailureDefinitionId(); if (failID == BuiltInFailures.WorksharingFailures.DuplicateNamesChanged) { fa.DeleteWarning(failure); } } }
/***************************************************/ /**** Private Event Handlers ****/ /***************************************************/ private static void ControlledApplication_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { bool hasFailure = false; FailuresAccessor failuresAccessor = e.GetFailuresAccessor(); List <FailureMessageAccessor> failureMessageAccessorsList = failuresAccessor.GetFailureMessages().ToList(); List <ElementId> elementsToDelete = new List <ElementId>(); foreach (FailureMessageAccessor failureMessageAccessor in failureMessageAccessorsList) { try { if (failureMessageAccessor.GetSeverity() == FailureSeverity.Warning) { failuresAccessor.DeleteWarning(failureMessageAccessor); continue; } else { failuresAccessor.ResolveFailure(failureMessageAccessor); hasFailure = true; continue; } } catch { } } if (elementsToDelete.Count != 0) { failuresAccessor.DeleteElements(elementsToDelete); } if (hasFailure) { e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit); } e.SetProcessingResult(FailureProcessingResult.Continue); }
private void Application_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { // Inside event handler, get all warnings var failList = e.GetFailuresAccessor().GetFailureMessages(); if (failList.Any()) { _undeleted++; foreach (var failure in failList) { // check FailureDefinitionIds against ones that you want to dismiss, var failId = failure.GetFailureDefinitionId(); // prevent Revit from showing Unenclosed room warnings if (failId == BuiltInFailures.EditingFailures.CannotEditDeletedElements) { e.GetFailuresAccessor().DeleteAllWarnings(); } } e.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack); } }
/// <summary> /// Обработчик предупреждений /// </summary> private static void Application_FailuresProcessing( object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { var failureAccessor = e.GetFailuresAccessor(); var failList = failureAccessor.GetFailureMessages(); if (!failList.Any()) { return; } if (failureAccessor.GetSeverity() == FailureSeverity.Warning) { failureAccessor.DeleteAllWarnings(); e.SetProcessingResult(FailureProcessingResult.Continue); } e.SetProcessingResult(failureAccessor.GetSeverity() == FailureSeverity.Error ? FailureProcessingResult.ProceedWithCommit : FailureProcessingResult.ProceedWithRollBack); }
public void Application_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { ExecuteEventHooks(EventType.Application_FailuresProcessing, sender, e); }
/// <summary> /// This is an event handler that responds to a failure according to the current settings /// </summary> /// <param name="sender">The sending object, i.e. the Revit application</param> /// <param name="e">The event arguments</param> public void AutoOptionsFailureHandler(Object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e) { //don't process if handling is turned off if (currentSettings.HandlingActive == false) { return; } //update the uiApp reference Application RevitApp = sender as Application; uiApp = new UIApplication(RevitApp); FailuresAccessor fa = e.GetFailuresAccessor(); //this is the action that will be taken to attempt resolution. Default is to continue the default Revit failure processing FailureProcessingResult action = FailureProcessingResult.Continue; foreach (FailureMessageAccessor fma in fa.GetFailureMessages()) { AutoFailureHandlingOptions aFOpts = currentSettings.AllFailureOptions .Where(x => x.FailureGuid == fma.GetFailureDefinitionId().Guid) .FirstOrDefault(); if (aFOpts != null) { //Show the CatchFailures dialog if a failure was caught if (currentSettings.InteractiveModeEnabled) { try { //todo: clone to allow roll-back? FailureCatcherWindow failWin = new FailureCatcherWindow(currentSettings, aFOpts, uiApp); Boolean?result = failWin.ShowDialog(); if (result.Value) { //Write changes to the .ini currentSettings.LastUpdate = DateTime.Now; IAutoOptionsRepository settingsRepo = new AutoOptionsConfigFileRepo(); settingsRepo.WriteAutoOptions(currentSettings); } } catch (Exception ex) { TaskDialog.Show("ex", ex.Message + "\n" + ex.StackTrace); throw; } } FailureResolutionOption selectedResolution = aFOpts.SelectedResolution; if (selectedResolution is AutoOptionsResolution) { try { switch (((AutoOptionsResolution)selectedResolution).Resolution) { case AutoOptionsResolutionType.NoAction: break; case AutoOptionsResolutionType.DeleteAffected: fa.DeleteElements(fma.GetFailingElementIds().ToList()); action = FailureProcessingResult.ProceedWithCommit; break; case AutoOptionsResolutionType.CancelTransaction: //todo: not working, being overwritten? action = FailureProcessingResult.ProceedWithRollBack; e.SetProcessingResult(action); fa.RollBackPendingTransaction(); return; case AutoOptionsResolutionType.HideWarning: //todo: check if actually is a warning? fa.DeleteWarning(fma); break; default: break; } } catch (Exception ex) { TaskDialog.Show("Dispatcher", ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace); } } else if (selectedResolution is RevitResolution) { try { FailureResolutionType fRT = ((RevitResolution)selectedResolution).Resolution; if (fma.HasResolutionOfType(fRT)) { fma.SetCurrentResolutionType(fRT); fa.ResolveFailure(fma); action = FailureProcessingResult.ProceedWithCommit; } else { TaskDialog.Show("AutoOptions", "The selected automatic resolution \n***" + aFOpts.SelectedResolution.FriendlyCaption + " (" + fRT + ")***\ncan't be used"); } } catch (Exception ex) { TaskDialog.Show("Dispatcher", ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace); } } } } e.SetProcessingResult(action); }