• Revit常用的元素过滤方法


    过滤器过滤元素

    • 创建过滤收集器
    Document document = revit.Application.ActiveUIDocument.Document;
    FilteredElementCollector collector = new FilteredElementCollector(document);  
    • 过滤元素
    1. 快速过滤
      collector.OfCategory(BuiltInCategory.OST_Walls).ofClass(typeof(FamilyInstance))
      OfCategory过滤类别,包括FamilySymbol及FamilyInstance,先通过OfCategory进行过滤可以提高效率,通过OfClass可以获取实例或者类型。
    2. 通用过滤
      LogicalAndFilter doorInstancesFilter =new LogicalAndFilter(familyInstanceFilter, doorsCategoryfilter);
      
      FilteredElementCollector collector = new FilteredElementCollector(document);
      
      ICollection<ElementId> doors = collector.WherePasses(doorInstancesFilter).ToElementIds();

    框选构件并筛选构件

    public class WallFilter : ISelectionFilter
    {
       public bool AllowElement(Element element)
       {
          if (element is Wall)
          {
             return true;
          }
          return false;
       }
       public bool AllowReference(Reference refer, XYZ point)
       {
          return false;
       }
    }
    // code in command
    IList<Element> elements = uiDoc.Selection.PickElementsByRectangle(new WallFilter(), "请选择墙");
    foreach (Element element in elements)
    {
       // do something
    }

  • 相关阅读:
    逆序对的相关问题:bzoj1831,bzoj2431
    bzoj3211,bzoj3038
    hdu 1179最大匹配
    hdu 3038带权并查集
    poj 1733离散化(map)+并查集
    codeforces 369B
    poj 1456
    POJ 1988相对偏移
    poj 1986tarjan模板题
    poj 1330lca模板题离线算法
  • 原文地址:https://www.cnblogs.com/shuai1991/p/13885794.html
Copyright © 2020-2023  润新知