如何select Revit中的所有族实例?
How to select all instances of family in Revit?
我正在为 Revit 2019 创建一个插件,并希望 select 通过 API 指定族和类型的所有实例。 "ElementClassFilter" 在 Revit sdk 中可用于过滤元素,但我想以蓝线显示所有相同类型的实例。我已经通过 "ElementClassFilter" 过滤了特定类型,但正在寻找如何通过 API.
在 revit 中 select 它们
以下代码用于过滤特定族和类型的元素。
ElementClassFilter filter = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.WherePasses(filter);
var query = from element in collector where element.Name == "Single-Standard" select element;
List<FamilyInstance> familyInstances = query.Cast<FamilyInstance>().ToList<FamilyInstance>();
但我想显示同一系列的所有实例并在下图中键入
"Window: Single-Standard" image
UIApplication UIapp = commandData.Application;
UIDocument UIdoc = UIapp.ActiveUIDocument;
Document doc = UIdoc.Document;
FilteredElementCollector elementCollector = new FilteredElementCollector(doc);
elementCollector.OfClass(typeof(FamilyInstance));
Selection sel = UIdoc.Selection;
sel.SetElementIds(elementCollector.ToList().Select(o => o.Id).ToList()); //User selection
这是一个关于如何设置用户选择的简单示例。
有关 revit Selection class 的更多信息,您可以访问此 link.
我正在为 Revit 2019 创建一个插件,并希望 select 通过 API 指定族和类型的所有实例。 "ElementClassFilter" 在 Revit sdk 中可用于过滤元素,但我想以蓝线显示所有相同类型的实例。我已经通过 "ElementClassFilter" 过滤了特定类型,但正在寻找如何通过 API.
在 revit 中 select 它们以下代码用于过滤特定族和类型的元素。
ElementClassFilter filter = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.WherePasses(filter);
var query = from element in collector where element.Name == "Single-Standard" select element;
List<FamilyInstance> familyInstances = query.Cast<FamilyInstance>().ToList<FamilyInstance>();
但我想显示同一系列的所有实例并在下图中键入
"Window: Single-Standard" image
UIApplication UIapp = commandData.Application;
UIDocument UIdoc = UIapp.ActiveUIDocument;
Document doc = UIdoc.Document;
FilteredElementCollector elementCollector = new FilteredElementCollector(doc);
elementCollector.OfClass(typeof(FamilyInstance));
Selection sel = UIdoc.Selection;
sel.SetElementIds(elementCollector.ToList().Select(o => o.Id).ToList()); //User selection
这是一个关于如何设置用户选择的简单示例。 有关 revit Selection class 的更多信息,您可以访问此 link.