简体   繁体   English

如何检索 Wall 的开口(不是坐标)?

[英]How to retrieve the openings of Wall (not the coordinates)?

我已经将级别检索为树视图(WPF 形式的树视图中的级别列表),然后从 Revit 项目中的特定级别(例如 Level1)中选择了一堵墙(例如 xyz_wall),我想检索列表开口(门和窗)选定的墙并显示到消息框(在消息框-开口列表中:)。

Window and Doors are FamilyInstances, and an Opening cut through a wall is an Opening object. Window 和 Doors 是 FamilyInstances,穿过墙的 Opening 是 Opening 对象。

private IList<Element> GetHostedElements(Wall wall)
{
    Document doc = wall.Document;
    
    ElementId id = wall.Id;
    
    IList<Element> result = new List<Element>();

    IEnumerable<Opening> openingInstances =
        new FilteredElementCollector(doc)
            .OfClass(typeof(Opening))
            .WhereElementIsNotElementType()
            .Cast<Opening>();

    foreach (Opening openingInstance in openingInstances)
    {
        if (openingInstance.Host.Id.Equals(id))
        {
            result.Add(openingInstance);
        }
    }

    IEnumerable<FamilyInstance> familyInstances =
        new FilteredElementCollector(doc)
            .OfClass(typeof(FamilyInstance))
            .WhereElementIsNotElementType()
            .Cast<FamilyInstance>();
                
    foreach (FamilyInstance familyInstance in familyInstances)
    {
        if (familyInstance.Host.Id.Equals(id))
        {
            result.Add(familyInstance);
        }
    }
    
    return result;          
}

If this answers your question, please accept the answer.如果这回答了您的问题,请接受答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM