【发布时间】:2018-02-06 15:10:49
【问题描述】:
我正在开发一个插件,它可以复制选定的工作表并以某种方式对其进行编辑。我通过使用ICollection<ElementId> selectedIds = uiDoc.Selection.GetElementIds();得到选择
当项目浏览器停靠时,这工作得非常好,但由于某种原因,当它没有停靠时它不起作用。
有没有办法在未停靠的项目浏览器中访问选择?
我尝试使用DockablePane projectBrowser = new DockablePane(DockablePanes.BuiltInDockablePanes.ProjectBrowser);
但我找不到任何成员可以从那里访问选择。
我做了以下小测试插件来演示:
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;
}
}
}
在停靠的项目浏览器中,它会返回您选择的元素数量,但在取消停靠时,它不起作用。否则是否可以访问此选择?
【问题讨论】: