Suppress FailureMessage on opening of a model

Suppress FailureMessage on opening of a model

Rockit_for_Revit
Advocate Advocate
524 Views
2 Replies
Message 1 of 3

Suppress FailureMessage on opening of a model

Rockit_for_Revit
Advocate
Advocate

Hello,

Is there any method where I can suppress FailureMessages on opening of a model?

I realise there is a method during a transation where the FailureMessage can be Deleted eg:

 

Dim failMessages As IList(Of FailureMessageAccessor) = failuresAccessor.GetFailureMessages()
For Each fma As FailureMessageAccessor In failMessages
   failure
    If fma.GetFailureDefinitionId = BuiltInFailures.RoomFailures.RoomNotEnclosed Then
        failuresAccessor.DeleteWarning(fma)
    End If
Next

However from what I undestand this can only be called during a transation eg:

Using Transaction As New Transaction(e.Document, "Handle Document Opened Failures")
    Dim failOpt As FailureHandlingOptions = Transaction.GetFailureHandlingOptions
    failOpt.SetFailuresPreprocessor(New SuppressRoomFailures)
    Transaction.SetFailureHandlingOptions(failOpt)
    Transaction.Start()
    Transaction.Commit()
End Using

Is there any way the warning can be suppressed without needing a transation e.g. from the DocumentOpened event?

I also need the same from space not enclosed but I can't seem to find SpaceNotEnclosed.

Rockit_for_Revit_0-1716780459392.png

 

Kind Regards

David

0 Likes
Accepted solutions (1)
525 Views
2 Replies
Replies (2)
Message 2 of 3

Mohamed_Arshad
Advisor
Advisor
Accepted solution

HI @Rockit_for_Revit 

 

        If we have a Warning it can be easily resolved. But For error, we don't have a resolution. We need to Subscribe FailuresProcessing Event in IExternalApplication class and implement your failure handling inside that event. This will suppress warnings on file opening. Kindly check the below code for additional reference.

 

Reference Code

 

public class RvtApp : IExternalApplication
    {
        public Result OnShutdown(UIControlledApplication application)
        {
            return Result.Succeeded;
        }

        public Result OnStartup(UIControlledApplication application)
        {
            application.ControlledApplication.FailuresProcessing += ControlledApplication_FailuresProcessing;

            return Result.Succeeded;
        }

        private void ControlledApplication_FailuresProcessing(object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
        {
            FailuresAccessor fa = e.GetFailuresAccessor();
            IList<FailureMessageAccessor> failList = new List<FailureMessageAccessor>();
            failList = fa.GetFailureMessages(); // Inside event handler, get all warnings
            foreach (FailureMessageAccessor failure in failList)
            {
                if (fa.GetSeverity()==FailureSeverity.Warning)
                {
                    fa.DeleteWarning(failure);
                }
            }

            e.SetProcessingResult(FailureProcessingResult.Continue);
        }
    }

 

 

Note:  The source code is on C# , Please convert it to VB.

Additional Reference on Failure Handling: https://spiderinnet.typepad.com/blog/2011/02/implement-a-revit-failuresprocessing-event-handler-with... 

 

Hope this will Helps 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 3 of 3

Rockit_for_Revit
Advocate
Advocate

Perfect thank you