首页/技术分享

二次开发教程:Revit开发获取房间内的构件

发布于:2019-08-26 16:45:55
9804人 分享

获取房间内的构件,大致思路如下


房间是有边界和高度的,所以我们可以得到房间的边界和高度


来构造一个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());

转载请注明来源本文地址:https://www.tuituisoft/blog/3483.html

上一篇:

二次开发教程:Revit开发通过轴网创建柱子

下一篇:

二次开发教程:Revit开发通过Category设置构件颜色