当前位置:网站首页>Revit secondary development - intercept project error / warning pop-up

Revit secondary development - intercept project error / warning pop-up

2022-07-07 22:23:00 Hey, hey, hey, hey, hey

Intercept errors in the project / Warning pop up .

public Result Execute(ExternalComandData commandData,ref string message,ElementSet elements)
{
    commandData.Application.Application.FailuresProcessing += Application_FailuresProcessing;
    return Result.Succeeded;
}

private void Application_FailuresProcessing(object sender,Autodesl.Revit.DB.Event.FailuresProcessingEventArgs e)
{
    FailuresAccessor fa = .GetDailureAccessor();
    IList<FailureMessageAccessor> lstFma = fa.GetFailureMessages();
    foreach(FailureMessageAccessor item in lstFma)
        {
            if(item.GetSeverity() == FailureSeverity.Warning)
            {
                fa.DeleteWarning(item);
                e.SetProcessingResult(FailureProcessingResult.Continue);
            }
            else if(item.GetSeverity() == FailureSeverity.Error)
            {
                if(item.HasResolutions())
                {
                    // error message 
                    string _failureMessage = fa.GetDescriptionText();
                    if( Is a negligible error )
                    {// Don't show error Popup 
                        FailureHandlingOptions fho = fa.GetFailureHandlingOptions();
                        fho.SetClearAfterRollback(true);
                        fa.SetFailureHandlingOptions(fho);
                    }
                    e.SetProcessingResult(FailureProcessingResult.ProceedWithRollBack);
                }
            }
        }
}

原网站

版权声明
本文为[Hey, hey, hey, hey, hey]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130606206658.html