Quantcast
Channel: RevitNetAddinWizard & NavisworksNetAddinWizard
Viewing all articles
Browse latest Browse all 872

Revit .NET API: Create Custom Dockable Pane (DockablePane) (pt. 5)

$
0
0

Revit .NET has provided the DockablePane API since version 2014. In this series of posts, we are going to explore the Revit DockablePane .NET API step by step.

In the first part, we created the simplest custom DockablePane to get the basic idea first about the DockablePane API. After that, we enhanced the custom DockablePane a bit and docked it to the ElementView window and created some code to show the custom DockablePane back in case it has been hidden. We also added a button to the custom DockablePane which will call the Revit Save command to save the current Revit model when being clicked.

In this post, we list out some information about the custom DockablePane and find out a serious limitation of the DockablePane API when doing so.

We add one more button to the layout of the Page1.xaml first.

        <Button Content="Get DockablePane Info" Height="23" HorizontalAlignment="Left" Margin="12,21,0,0" Name="button2" VerticalAlignment="Top" Width="276" Click="button2_Click" />

Next, we add the following button callback and idling event handler to the code-behind file, Page1.xaml.cs:

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            string msg = "Information about the DockablePane:\n";

            DockablePane pane = ExtApp._cachedUiCtrApp.GetDockablePane(ExtApp.paneId);
            if (pane != null)
            {
                msg += "\nTitle: " + pane.GetTitle();
                msg += "\nType: " + pane.GetType();
                msg += "\nId: " + pane.Id.Guid.ToString();
                msg += "\nIsValie: " + pane.IsValidObject;
            }

            System.Windows.Forms.MessageBox.Show(msg);
        }

That is about it. Now we can press the F5 key to test it. This time, the Page1 DockablePane has one more button besides the Save button at the middle center and the underlying image that were added before. When the button is clicked the some information about the DockablePanel will be displayed in a message box.
DockablePaneButtonInfo
 
However, it was found out that the DockablePanel has a serious limitation. That is, it does not carry any information about the hosted WPF Page/Window at all, and this fact makes it impossible to resize the pane, relocate it, or change any status of the DockablePane programmatically if nothing is done about it. In the coming post, we will work around the issue.

Revit Addin Wizard (RevitAddinWizard) provides various wizards, coders and widgets to help program Revit addins. It can be downloaded from the Download link at the bottom of the blog index page.


Viewing all articles
Browse latest Browse all 872

Trending Articles