View view = document.ActiveView;//活跃视图
ElementId elementId = view.Id;
FilteredElementCollector elements = new FilteredElementCollector(document, elementId);
房间过滤器RoomFilter ;
RoomFilter roomFilter = new RoomFilter();
List<Room> rooms = elements.WherePasses(roomFilter).Cast<Room>().ToList();
foreach (Room item in rooms)
{
//删除房间标记,但是房间明细表里还是会存在,它的Location=null
if (item.Level.Name.Equals("标高 2") && item.Location != null)
{
}
}
元素相交过滤器BoundingBoxIntersectsFilter;
//得到房间
Room room = document.GetElement(new ElementId(555555)) as Room;
//得到房间的编辑框
BoundingBoxXYZ boundingBoxXYZ = room.get_BoundingBox(view);
//通过编辑框创建一个outline
Outline outline = new Outline(boundingBoxXYZ.Min, boundingBoxXYZ.Max);
//得到元素边界过滤器
BoundingBoxIntersectsFilter boundingBoxIntersectsFilter = new BoundingBoxIntersectsFilter(outline);
//房间边界框相交(也边界框内的元素)的所有元素
IList<Element> elements = collector.WherePasses(boundingBoxIntersectsFilter).ToElements();
foreach (var item in elements)
{
if (item is Wall)
{
}
if (item is FamilyInstance)
{
}
//类型是桌子 根据指定类型过滤
if (item.Category.Id.IntegerValue == -2000080)
{
}
}
元素包含过滤器BoundingBoxIsInsideFilter;
元素类别过滤器ElementCategoryFilter等同于OfCategory;
ElementCategoryFilter elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
IList<Element> elements2 = collector.WherePasses(elementCategoryFilter).ToElements();
元素过滤器ElementFilter等同于OfClass()
新建QQ群:713878394