【问题标题】:How to retrieve the openings of Wall (not the coordinates)?如何检索墙的开口(不是坐标)?
【发布时间】:2021-12-27 05:49:24
【问题描述】:

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

【问题讨论】:

    标签: c# revit-api revitpythonshell pyrevit revit-2015


    【解决方案1】:

    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;          
    }
    

    如果这回答了您的问题,请接受答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      • 1970-01-01
      相关资源
      最近更新 更多