DialogBoxShowing event not firing when model is opened.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
After smashing my face against this problem and pouring through the API documentation/building coder blog I'm stumped. I can't get the DialogBoxShowing event to fire while opening a document, either manually or via the API. Note that this is very similar to the problem mentioned here: http://forums.autodesk.com/t5/revit-api/dialogboxshowing-event-not-firing-when-model-is-opened/m-p/5... If I'm reading the answer correctly, the problem could not be reproduced, so I've tried to boil the problem down to a few simple reproducible steps.
Steps:
1. Create a new RVT file.
2. Create a new blank DWG file.
3. Link the DWG file into the RVT file, you will get a warning "Import detected no valid elements in the file's Model space. Do you want to import from the Paper space?" This will also trigger the DialogBoxShowing event.
4. Save the RVT and close.
5. Open the RVT file you just created. You'll get the same warning, but no event will trigger.
6. Run the code below, using OpenDoucmentFile. Same thing, warning, no event.
Here is the code I am also using to reproduce this behavior:
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using Autodesk.Revit; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Events; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using System.Management; namespace Dialog { [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)] [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)] public class Class1 : IExternalApplication { public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application) { MessageBox.Show("Registering event handler"); application.DialogBoxShowing += new EventHandler<DialogBoxShowingEventArgs>(HandleDialogBoxShowing); application.ControlledApplication.ApplicationInitialized += new EventHandler<ApplicationInitializedEventArgs>(appinitialized); return Result.Succeeded; } public static void HandleDialogBoxShowing(object sender, Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs dialogargs) { TaskDialogShowingEventArgs taskargs = dialogargs as TaskDialogShowingEventArgs; MessageBox.Show("Dialog about to show."); } public static void appinitialized(object sender, ApplicationInitializedEventArgs e) { Document doc = null; Autodesk.Revit.ApplicationServices.Application applin = sender as Autodesk.Revit.ApplicationServices.Application; UIApplication uiApp = new UIApplication(applin); doc = uiApp.Application.OpenDocumentFile(@"C:\not showing.rvt"); } public Autodesk.Revit.UI.Result OnShutdown(UIControlledApplication application) { return Autodesk.Revit.UI.Result.Succeeded; } } }
I would really like to be able to handle this message but I can't get the event to trigger. Is this intended behavior? Any work around anyone has come across?