当前位置:网站首页>Revit secondary development - shielding warning prompt window

Revit secondary development - shielding warning prompt window

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

Happy new year to you all , Good luck in the year of the ox , Pay doubled

Implementation interface

public class FailurePreprocessor : IFailuresPreprocessor
{
    private string _failureMessage;
    public string FailureMessage
    {
        get{return _failureMessage;}
        set{_failureMessage=value;}
    }
    private bool _error;
    public bool HasError
    {
        get{return _error;}
        set{_error = value;}
    }
    public FailureProcessingResult PreprocessFailures(FailuresAccessor fa)
    {
        IList<FailureMessageAccessor> lstFma = fa.GetFailureMessages();
        if(lstFma.Count() == 0) return FailureProcessingResult.Continue;
        foreach(FailureMessageAccessor item in lstFma)
        {
            if(item.GetSeverity() == FailureSeverity.Warning)
            {
                _error = false;
                fa.DeleteWarning(item);
            }
            else if(item.GetSeverity() == FailureSeverity.Error)
            {
                if(item.HasResolutions())
                {
                    fa.ResolveFailure(item);
                    _failureMessage = fa.GetDescriptionText();
                    _error = true;
                    return FailureProcessingResult.ProceedWithRollBack;
                }
            }
        }
        return FailureProcessingResult.Continue;
    }
}

call

using(Transcation trans = new Transcation(doc,"hey"))
{
    FailureHandlingOptions fho = trans.GetFailureHandlingOptions();
    fho.SetFailuresPreprocessor(new FailuresPreprocessor());
    trans.SetFailureHandlingOptions(fho);
    trans.Start();
    //
    //
    //
    trans.Commit();
}

原网站

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