Revit API implements dockable windows

Source: Internet
Author: User

---restore content starts---

1. Create a new Class library project, and the new WPF user Control (UserControl) in the project gets an instance named UserControl1.

The parent class of dockable windows in Revit is the page class, and also inherits the Idockablepaneprovider interface.

Therefore, the relevant place needs to be changed to the content shown in the figure.

2. Next you need to implement the Setupdockablepane () function in the interface in the hidden code to initialize the window state.

 1  public  void   Setupdockablepane (dockablepaneproviderdata Data)  2   { 3
     data.frameworkelement = this  as FrameworkElement;  4  5  data.initialstate = new   Dockablepanestate ();  6  Data.InitialState.DockPosition = Dockposi tion. Bottom;  7  8 } 

This completes our UserControl1.

And our window will appear at the bottom.

3. Next, register a dockable window in Revit (incidentally, add a command button)

1 Static stringPath =typeof(Panel). assembly.location;2         3          PublicResult Onstartup (uicontrolledapplication application)4         {5Ribbonpanel Ribbonpanel = Application. Createribbonpanel ("window");6 7Pushbutton pushbutton = Ribbonpanel.additem (NewPushbuttondata8("DockPanel1","can be docked", Path,"dockpanel.test")) aspushbutton;9 Ten             stringPageguid ="2ab776b4-b3fc-4810-8f44-ab5f1c9f5fa8"; OneGUID GUID =NewGuid (pageguid); ADockablepaneid ID =NewDockablepaneid (GUID); -UserControl1 Panel1 =NewUserControl1 (); -Application. Registerdockablepane (ID,"dockpaneltest", Panel1 asidockablepaneprovider); the  -             returnresult.succeeded; -}

The core approach is

1  Public void Registerdockablepane (2    dockablepaneid ID,3     string  Title,4    idockablepaneprovider provider5 )

Panel1 is an example of a previously written UserControl1, UserControl1 inherits the Idockablepaneprovider interface.

4. Finally, the button command code

1 [Transaction (transactionmode.manual)]2 [Regeneration (regenerationoption.manual)]3 [Journaling (Journalingmode.nocommanddata)]4      Public classTest:iexternalcommand5     {6         7          PublicResult Execute (Externalcommanddata commanddata,ref stringmessage, ElementSet Element)8         {9             stringPageguid ="2ab776b4-b3fc-4810-8f44-ab5f1c9f5fa8";TenGUID GUID =NewGuid (pageguid); OneDockablepaneid ID =NewDockablepaneid (GUID); A  -Dockablepane Panel =CommandData.Application.GetDockablePane (ID); - panel. Show (); the  -             returnresult.succeeded; -         } -}

5. After the build is successful, write the addin file and open Revit to see the dockable window.

Revit API implements dockable windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.