Message 1 of 6
RegisterDockablePane from Eventhandler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
i Just started building addins for Revit, my c# skill are not that good yet, and have a question about registering a DockableDialog from an event.
All the examples i have found so far work with buttons that the user needs to click, i want it to be registered when Revit starts.
I searched on this forum and on google but i haven't found a solution for this problem.
i got the code for the ApplicationInitialized event, if i want to show a taskdialog (as test) it works fine, if i want to RegisterDockablePane is gives errors with the debug proces(see attached images in the spoiler).
the codes is pretty simple i think:
public class RegisterApp : IExternalApplication { testform m_MyDockableWindow = null; public Result OnStartup(UIControlledApplication a) { a.ControlledApplication.ApplicationInitialized += OnApplicationInitialized;//call OnApplicationInitialized after revit launches a.ControlledApplication.DocumentOpened += new EventHandler<Autodesk.Revit.DB.Events.DocumentOpenedEventArgs>(OnDocumentOpened); return Result.Succeeded; } //OnApplicationInitialized register dockable dialog public void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e) { UIApplication uiapp = sender as UIApplication; Application app = sender as Application; DockablePaneProviderData data = new DockablePaneProviderData(); testform MainDockableWindow = new testform(); m_MyDockableWindow = MainDockableWindow; data.FrameworkElement = MainDockableWindow as System.Windows.FrameworkElement; data.InitialState = new DockablePaneState(); data.InitialState.DockPosition = DockPosition.Tabbed; data.InitialState.TabBehind = DockablePanes.BuiltInDockablePanes.PropertiesPalette; DockablePaneId dpid = new DockablePaneId(new Guid("{54761517-118C-4A9A-938D-62384E4BAD72}")); uiapp.RegisterDockablePane(dpid, "name of dockable pane", MainDockableWindow as IDockablePaneProvider);//this line give an error, everything above works fine TaskDialog td = new TaskDialog("The applicationInitializedEvent worked");//this taskdialog is a test to see if the code works td.Show();
}
Is it possible to register with an event, if so, how?
Thanks
Martin B