I have created add small addin for auto export of PDF. I works fine as long as there is no errors like the one on the image when Revit working on opening the project. I can close a number of errors, but some still pose problems.
I have used the following guidance from The Building Coder: http://thebuildingcoder.typepad.com/blog/2014/05/on-handling-warnings-and-failures.html
Hi,
Have you also seen http://thebuildingcoder.typepad.com/blog/2016/09/warning-swallower-and-roomedit3d-viewer-extension.h... ?
Is the dialog a warning or error? Is the dialog a taskdialog? Does it have a dialog Id? (Check the journal file.)
Hi Matt,
I had not seen that blogpost. Thank you for the link. It looks very similar to what I am looking for. I will see if it can help me some time this weekend.
I cannot catch the dialog in my code so I am not sure whether it is a warning or error.
Normally warring’s have a different dialog so I think that it is an “error”.
Hi @nvoW4TBM,
Great. When the error/warning dialog pops up, go straight to your journal and take a look. It looks like it is a basic taskdialog, so you can do something like this:
'Initialise event handler AddHandler m_appUi.DialogBoxShowing, AddressOf DialogBoxShowingCall 'remove it when you don't need it anymore. RemoveHandler m_appUi.DialogBoxShowing, AddressOf DialogBoxShowingCall
'the sub the event calls - just explore what happens for your models and close dialogs as required Private Sub DialogBoxShowingCall(sender As Object, e As UI.Events.DialogBoxShowingEventArgs) Dim e2 As UI.Events.TaskDialogShowingEventArgs = _
TryCast(e, UI.Events.TaskDialogShowingEventArgs) Dim e3 As UI.Events.MessageBoxShowingEventArgs = _
TryCast(e, UI.Events.MessageBoxShowingEventArgs) Dim s As String = String.Empty If e2 IsNot Nothing Then Dim dialogId2 As String = String.Empty Debug.Print(String.Format("DialogBoxShowing: help id {3}, dialog id {0}, cancellable {1}{2}", _
e2.DialogId, If(e2.Cancellable, "Yes", "No"), s, dialogId2)) If e2.DialogId.Equals("TaskDialog_Detach_Model_From_Central", _
StringComparison.InvariantCultureIgnoreCase) Then Debug.Print("DialogBoxShowing: PreserveWorksets") e2.OverrideResult(CInt(UI.TaskDialogResult.CommandLink1)) ElseIf e2.DialogId.Equals("TaskDialog_Unresolved_References", _
StringComparison.InvariantCultureIgnoreCase) Then Debug.Print("DialogBoxShowing: Unresolved References") e2.OverrideResult(CInt(UI.TaskDialogResult.CommandLink2)) End If End If Dim dialogId As String = e.DialogId Debug.Print("DialogBoxShowing: help id {0}, cancellable {1}{2}", _
dialogId, If(e.Cancellable, "Yes", "No"), s) End Sub
Now I get a different error that I can't close..
' 6:< Invoked HandleDocFailure
' 6:< Error dialog has no callback because
'it was not provided in following error in error message
'The dimension segment containing the override(s) shown below has been removed. The override text will no longer appear.
'Value:Variabel
' 6:< Error dialog data for transaction Reload Linked Instances in Host document
' 6:< Warning: The dimension segment containing the override(s) shown below has been removed. The override text will no longer appear.
'Value:Variabel
' 6:< Error dialog summary
' 6:< Warning: The dimension segment containing the override(s) shown below has been removed. The override text will no longer appear.
'Value:Variabel - 1 times
'H 17-Mar-2017 11:56:00.580; 6:<
Jrn.Data "Error dialog" _
, "0 failures, 0 errors, 1 warnings"
You'll always come up against something like that eventually. Check this out:
http://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html
There may be something more recent. Just search for Windows API.
I ran into something similar not very long ago. Jeremy pointed me towards this warning swallower:
https://thebuildingcoder.typepad.com/blog/2018/09/swallowing-stairsautomation-warnings.html
ErrorHandling this way is much more versatile than the dialogboxshowingevent. You might want to check it out.
It took some time for me to get how it works, but it's really, really handy once you get it.