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

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

$
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 this part, we create the simplest custom DockablePane to get the basic idea first about the DockablePane API.

•    Use the Revit .NET Addin Wizard (RevitNetAddinWizard) to create a C# addin project for Revit 2014. To make it as simple as possible, we only need to name the project name as SimplestDockablePane and accept any other default settings.

•    Manully upgrade the project type of the SimplestDockablePane.csproj from Class Library to WPF User Control Library through adding the <ProjectTypeGuids> element to the Project/PropertyGroup:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

•    Now we can add a WPF Page to the DLL project. In the future, the Revit .NET Addin Wizard (RevitNetAddinWizard) will support the WPF User Control Library directly. Right click at the project name and choose Add -> Page.

•    Open the code-behind file (Page1.xmal.cs) of the Page1.xaml and add one more namespace:

using Autodesk.Revit.UI;

•    Add the IDockablePaneProvider interfact to the Page1 declaration to make it look like:

public partial class Page1 : Page, IDockablePaneProvider

•    Add the following method to the class:

public void SetupDockablePane(DockablePaneProviderData data)
{
data.FrameworkElement = this;

data.InitialState.DockPosition = DockPosition.Tabbed;
data.InitialState.TabBehind = Autodesk.Revit.UI.DockablePanes.BuiltInDockablePanes.PropertiesPalette;
}

•    Add the DockablePane registration code to the OnStartup of the ExtApp:

//TODO: add you code below.

Page1 page1 = new Page1();
DockablePaneId paneId = new DockablePaneId(Guid.NewGuid());
uiApp.RegisterDockablePane(paneId, "Page1", (IDockablePaneProvider)page1 );

That is about it. A complete working custom DockablePane addin has been successfully done and we are ready to press the F5 key to give it a try in the Revit 2014, as chosen during the project creation time by Revit .NET Addin Wizard (RevitNetAddinWizard).

We will notice that the Page1 Dockable Pane appears side by side with the Properties tab in the Properties parent dialog, as red-lined below.

DockablePaneToProperties
 

When it is clicked, we will see its content is as expected empty. We are going to enhance it a bit next. Please stay tuned.


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

Latest Images

Trending Articles



Latest Images