I'm working on an addin that copies the selected sheets and edits them in some ways. I get the selection by using ICollection<ElementId> selectedIds = uiDoc.Selection.GetElementIds();
This works perfectly fine when the project browser is docked, but for some reason it doesn't work when it's not docked.
Is there any way to access the selection in the undocked project browser?
I tried using
DockablePane projectBrowser = new DockablePane(DockablePanes.BuiltInDockablePanes.ProjectBrowser);
but I can't find any member to acces the selection from there.
I made the following small test addin to demonstrate:
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
namespace Test
{
[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
public class Test : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Document doc = uiDoc.Document;
ICollection<ElementId> selectedIds = uiDoc.Selection.GetElementIds();
int count = selectedIds.Count();
if (count != 0)
{
TaskDialog.Show("test", "Selection: " + count.ToString() + " elements.");
}
else
{
TaskDialog.Show("test", "No selection");
}
return Result.Succeeded;
}
}
}
In a docked project browser, it returns the number of elements that you've selected but when it's undocked, it doesn't work. Is it possible to access this selection otherwise?