I am an Architect relatively new to C#, I am trying to implement Ehsan Iran-Nejad's amazing PyRevit coloured tabs in my own toolbar.
Unfortunately for me, this is returning null:
public static Xceed.Wpf.AvalonDock.DockingManager GetDockingManager(UIApplication uiapp)
{
var wndRoot = (MainWindow)UIAppEventUtils.GetWindowRoot(uiapp);
if (wndRoot != null)
{
return MainWindow.FindFirstChild<Xceed.Wpf.AvalonDock.DockingManager>(wndRoot);
}
return null;
}
Launched from the external command:
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class StartGroupingTabsExt : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
if(DocumentTabEventUtils.IsUpdatingDocumentTabs)
{
DocumentTabEventUtils.StopGroupingDocumentTabs();
}
else
{
DocumentTabEventUtils.StartGroupingDocumentTabs(commandData.Application);
}
return Result.Succeeded;
}
}
I cannot see quite what is going wrong.
I've had something similar happening when I was building something like that. I had referenced the xceed.wpf.avalondock library from nuget and that was what caused it. Maybe you did the same thing? If I instead referenced the dll that's in the Revit installation folder, it worked without a problem.