Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66666

Re: A question about suppressing warning messages in Revit

$
0
0

Thanks Mustafa.Salaheldin.
I used the above code,but there will be error:

 private void FaliureProcessor(object sender, FailuresProcessingEventArgs e)
        {

            bool hasFailure = false;

            FailuresAccessor fas = e.GetFailuresAccessor();

            List<FailureMessageAccessor> fma = fas.GetFailureMessages().ToList();

            foreach (FailureMessageAccessor fa in fma)
            {
                try
                {
                    if (fa.GetFailureDefinitionId() == BuiltInFailures.OverlapFailures.DuplicateInstances)
                    {
                        //use the following lines to delete the warning elements
                        List<ElementId> elemntsToDelete = fa.GetFailingElementIds().ToList();

                        IList<ElementId> elemntToDelete = new List<ElementId>();
                        elemntToDelete.Add(elemntsToDelete[0]);
                        fas.DeleteElements(elemntToDelete);
                        fas.DeleteWarning(fa);
                        hasFailure = true;

                        //use the following line to disable the message supressor after the external command ends
                        CachedUiApp.Application.FailuresProcessing -= FaliureProcessor;
                    }
                }
                catch (Exception ex)
                {
                      TaskDialog.Show("`1", ex.ToString());

                }

            }
            if(hasFailure)
            {
                e.SetProcessingResult(FailureProcessingResult.ProceedWithCommit);
            }

            e.SetProcessingResult(FailureProcessingResult.Continue);
        }

1.png

What reason is this?


Viewing all articles
Browse latest Browse all 66666

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>