I have used Revit custom export of a model for exporting a 3D View based on IExportContext. It works fine. But I found that the export process can be Canceled (see screen below) Custom export canceling Then appears a dialog Dialog screen I have 2 questions:
- How to get info that exporting was canceled?
- Why the name of operation is Printing (see Dialog screen shot)
Thanks Jeremy for provided solution in Revit 2021. ViewsExportedByContext works but only in the 2021 version.
Application.ViewsExportedByContext += Application_ViewsExportedByContext;
private void Application_ViewsExportedByContext(object sender, ViewsExportedByContextEventArgs e)
{
if (e.Status == RevitAPIEventStatus.Failed)
{
// Export was cancelled
}
UPDATE:
We have found the solution for Revit lower 2021.
There is the event in UIApplication:
public event EventHandler<Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs> DialogBoxShowing
The idea is simple: if the Cancellation dialog appears and then the method of interface IExportContext
RenderNodeAction OnElementBegin(ElementId elementId)
was called, that means the user selected "NO" in cancellation dialog or other dialog appeared. But if the method of interface IExportContext
void Finish()
was called that means user selected "YES" in cancellation dialog.