Boost Your BIM – making Revit even better

February 1, 2013

How to Automatically Dismiss a Revit dialog

Filed under: Events, UI — Harry Mattison @ 12:09 pm

For my friend who asked:

Is it possible to disable the pop-up, when you edit a floor: -Would you like walls that go up to his floor’s level to attach to its bottom?- I never want to do this, it’s annoying

Here is how to automatically dismiss that or any other Message Box or Task Dialog

private void Module_Startup(object sender, EventArgs e)
{
    UIApplication uiapp = new UIApplication(this.Application);
    // Subscribe to the DialogBoxShowing event to be notified when Revit is about to show a dialog box or a message box. 
    uiapp.DialogBoxShowing += new EventHandler<DialogBoxShowingEventArgs>(dismissFloorQuestion);
}

private void dismissFloorQuestion(object o, DialogBoxShowingEventArgs e)
{
    // DialogBoxShowingEventArgs has two subclasses - TaskDialogShowingEventArgs & MessageBoxShowingEventArgs
    // In this case we are interested in this event if it is TaskDialog being shown. 
    TaskDialogShowingEventArgs t = e as TaskDialogShowingEventArgs;
    if (t != null && t.Message == "The floor/roof overlaps the highlighted wall(s). Would you like to join geometry and cut the overlapping volume out of the wall(s)?")
    {
        // Call OverrideResult to cause the dialog to be dismissed with the specified return value
        // (int) is used to convert the enum TaskDialogResult.No to its integer value which is the data type required by OverrideResult
        e.OverrideResult((int)TaskDialogResult.No);
    }
}
About these ads

3 Comments »

  1. Please remember that the text will not always be in English! It comes from resources and will be properly localized in foreign versions of Revit. Using the string locally is all right, but it is better to rely on Dialog Id, which should also be available (although not always is) in the event argument.
    Arnošt Löbel

    Comment by Arnošt Löbel — February 1, 2013 @ 3:59 pm

  2. I am sorry for the newbish Question, but could you give a more comprehensive guide on how to add this code to revit? This has been driving me crazy and I cannot believe that such an advanced and expensive software as Revit does not have the functionality to disable useless prompts automatically.

    Comment by deven — March 15, 2013 @ 2:24 am

  3. Ok, I got it to work. I needed to add “using Autodesk.Revit.UI.Event”
    Thanks a lot for the great code!

    Comment by deven — March 15, 2013 @ 3:46 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The WordPress Classic Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 972 other followers