1. Door在Revit里面的element类型是FamilyInstance。 
2. Door在Revit里面的category类型是OST_Doors。 
3. 想要过滤特定类型的element需要ElementClassFilter。 
4. 想要过滤特定类型的category需要ElementCategoryFilter。 
5. 想要让两种类型的filter同时起作用需要LogicalAndFilter。 
6. 找到文档(Document)里的element需要FilteredElementCollector,可以将其认为是文档中element的管理器。 
7. 将filter传递给FilteredElementCollector即可得到所有能够通过filter的element。

 

 1 public ICollection<Element> CreateDoorFilter(Autodesk.Revit.DB.Document document)
 2 {
 3     // 找到当前项目中所有的 family instances,并且它们的 category 是 door。
 4     // 创建 ElementClassFilter 过滤器用以获得所有的 FamilyInstance。
 5     ElementClassFilter familyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));
 6 
 7     // 创建 ElementCategoryFilter 过滤器用以获得所有的 OST_Doors。
 8     ElementCategoryFilter doorsCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
 9 
10     // 创建 logic And filter 将上面的两个过滤器合并。
11     LogicalAndFilter doorInstancesFilter = new LogicalAndFilter(familyInstanceFilter, doorsCategoryfilter);
12 
13     // 将上面的过滤器应用到当前活动的 document。
14     FilteredElementCollector collector = new FilteredElementCollector(document);
15     IList<Element> doors = collector.WherePasses(doorInstancesFilter).ToElements();
16 
17     return doors;
18 }

 

相关文章:

  • 2021-11-28
  • 2021-12-22
  • 2022-12-23
  • 2021-10-06
  • 2022-01-24
  • 2022-02-10
  • 2021-07-24
  • 2021-09-11
猜你喜欢
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-12-11
  • 2021-10-15
  • 2021-10-16
相关资源
相似解决方案