Capture Warning message during the save with a Revit Batch Startup approach
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I would like to capture the warning messages during the save when I am launching Revit in background (Batch).
I am currently not able to activate the FailUI class to capture the warning message during the save with this Revit startup approach. Is there a public API which allow this operation?
I provide you a sample of code to illustrate my words.
namespace TEST1
{
/// <summary>
/// This application's main class. The class must be Public.
/// </summary>
public class ProjectAddPanel : IExternalApplication
{
public Result OnStartup(UIControlledApplication application)
{
application.ControlledApplication.ApplicationInitialized += new EventHandler<Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs>(TestBatch);
Autodesk.Revit.DB.IFailuresProcessor MyFailUI = new FailUI();
Autodesk.Revit.ApplicationServices.Application.RegisterFailuresProcessor(MyFailUI);
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
application.ControlledApplication.ApplicationInitialized -= new EventHandler<Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs>(TestBatch);
return Result.Succeeded;
}
public void TestBatch (object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
{
// Sender is an Application instance:
Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
// However, UIApplication can be instantiated from Application.
UIApplication uiapp = new UIApplication(app);
// Open File
uiapp.OpenAndActivateDocument(« test.rvt »);
UIDocument uidoc = uiapp.ActiveUIDocument;
Doc = uidoc.Document;
Doc.Save();
}
}
public class FailUI : IFailuresProcessor
{
public void Dismiss(Document document)
{
// This method is being called in case of exception or document destruction to
// dismiss any possible pending failure UI that may have left on the screen
}
public FailureProcessingResult ProcessFailures(FailuresAccessor failuresAccessor)
{
failuresAccessor.DeleteAllWarnings();
return FailureProcessingResult.Continue;
}
}
}
}