下載app免費領取會員
獲取房間內的構件,大致思路如下
房間是有邊界和高度的,所以我們可以得到房間的邊界和高度
來構造一個Solid,然后用過濾和這個Solid相交的構件
Revit API 提供了SpatialElementGeometryCalculator 這個類
可以方便的獲取到房間的Solid
注意:這個Solid無法過濾到房間內部為房間邊界的構件,如建筑柱勾選了房間邊界后就過濾不到了
代碼如下:
ElementId roomId = new ElementId(313062);
Document doc = commandData.Application.ActiveUIDocument.Document;
Room room = doc.GetElement(roomId) as Room;
SpatialElementGeometryCalculator segc = new SpatialElementGeometryCalculator(doc);
SpatialElementGeometryResults segr = segc.CalculateSpatialElementGeometry(room);
Solid solid = segr.GetGeometry();
FilteredElementCollector temc = new FilteredElementCollector(doc);
ElementIntersectsSolidFilter filter = new ElementIntersectsSolidFilter(solid);
temc.WherePasses(filter);
TaskDialog.Show("Num", temc.Count().ToString());
本文版權歸腿腿教學網及原創(chuàng)作者所有,未經授權,謝絕轉載。
上一篇:二次開發(fā)教程:Revit開發(fā)通過軸網創(chuàng)建柱子
下一篇:二次開發(fā)教程:Revit開發(fā)通過Category設置構件顏色
推薦專題