Autodesk.Revit.DB.BoundingBoxIntersectsFilter
类是Revit API中的一个筛选器(Filter),它可用于在Revit中选择其边界框(BoundingBox)与给定的另一个边界框相交的元素。
public BoundingBoxIntersectsFilter(BoundingBox boundingBox)
boundingBox
: 需要使用的边界框。// 获取与给定边界框相交的所有墙体
BoundingBox boundingBox = new BoundingBox(new XYZ(0,0,0), new XYZ(10,10,10));
BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(boundingBox);
IList<Element> walls = new FilteredElementCollector(document).OfClass(typeof(Wall)).WherePasses(filter).ToList();
// 获取当前视图中与视图范围边界框相交的所有元素
BoundingBox viewBoundingBox = new BoundingBox(view.Origin, view.TopRight);
BoundingBoxIntersectsFilter viewFilter = new BoundingBoxIntersectsFilter(viewBoundingBox);
IEnumerable<ElementId> elementsInView = new FilteredElementCollector(document, view.Id).WherePasses(viewFilter).ToElementIds();
System.ArgumentNullException
: 如果传入的boundingBox
是null
。该类在Revit API 2017版本以后引入。