问题:如何通过柱子找到他连接的所有墙?
柱子和墙之间的关系无法直接通过API来获得,只能通过相交过滤间接来获得。
你可以直接用 ElementIntersectsElementFilter 或ElementIntersectsSolidFilter 这两个过滤条件类来实现。
这两个类的用法请参考RevitAPI.chm文档。
ElementIntersectsSolidFilter需要你给定一个Solid,然后就会找到与指定Solid相交的其他构件。
示例代码如下:
// Find intersections between family instances and a selected element
Reference reference = uidoc.Selection.PickObject(ObjectType.Element, "Select element that will be checked for intersection with all family instances");
Element element = doc.GetElement(reference);
GeometryElement geomElement = element.get_Geometry(new Options());
Solid solid = null;
foreach (GeometryObject geomObj in geomElement)
{
solid = geomObj as Solid;
if (solid != null) break;
}
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(FamilyInstance));
collector.WherePasses(new ElementIntersectsSolidFilter(solid)); // Apply intersection filter to find matches
TaskDialog.Show("Revit", collector.Count() + " family instances intersect with the selected element (" + element.Category.Name + " id:" + element.Id + ")");
如此类推,你可以获取柱子的Solid,传给ElementIntersectsSolidFilter的实例来获取与柱子相交的构件,过滤出墙即可。
作者:叶雄进, Autodesk特聘二次开发咨询专家, 橄榄山软件首席研发
转载请注明原文出处:http://blog.csdn.net/joexiongjin/article/details/41090861