- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I am not quite sure how to solve and hide error messages genereated by copy/paste in API.
I have this which hides warning messages and deletes the elements causing an error,this works ok but still shows the error message to the user:
'suppress all warnings
For Each f As FailureMessageAccessor In failList
Dim fs As FailureSeverity = fa.GetSeverity
Select Case fs
Case FailureSeverity.Warning
'hide messages of severity "Warning"
fa.DeleteWarning(f)
Case FailureSeverity.Error
Dim elist As List(Of ElementId) = f.GetFailingElementIds
fa.DeleteElements(elist)
fa.ResolveFailure(f)
Return FailureProcessingResult.ProceedWithCommit
Case Else
Return FailureProcessingResult.ProceedWithRollBack
End Select
Next
This is called by the transaction options:
If t.Start() = TransactionStatus.Started Then
Dim FailOpt As FailureHandlingOptions = t.GetFailureHandlingOptions()
FailOpt.SetFailuresPreprocessor(New myFailurePreProcessor())
t.SetFailureHandlingOptions(FailOpt)
I have seen Jeremy's post of May 7 2014 on handling warnings and failures and adapt the example c# code to vb as:
Private Sub DoFailureProcessing(sender As Object, args As Autodesk.Revit.DB.Events.FailuresProcessingEventArgs)
Dim failuresAccessor As FailuresAccessor = args.GetFailuresAccessor()
'failuresAccessor
Dim fmas As IList(Of FailureMessageAccessor) = failuresAccessor.GetFailureMessages()
If fmas.Count = 0 Then
args.SetProcessingResult(FailureProcessingResult.[Continue])
Return
End If
For Each fma As FailureMessageAccessor In fmas
Dim id As FailureDefinitionId = fma.GetFailureDefinitionId()
failuresAccessor.ResolveFailure(fma)
Next
args.SetProcessingResult(FailureProcessingResult.ProceedWithCommit)
Return
End Sub
What I am struggling with is how to get the DoFailureProcessing code to be triggered?
(I am using Revit 2016, VS2012 and VBdotNet)
Any help appreciated
Paul
Solved! Go to Solution.