【问题标题】:Revit families and filtering elementsRevit 族和过滤图元
【发布时间】:2011-09-26 03:31:16
【问题描述】:

我需要按系列过滤所选元素。

我们有一个木梁族,我只需要修改属于木梁族的选定元素。我在网上查看过,但找不到任何可以告诉我如何操作的东西。我是 revit 新手。

//get all instaces if family objects
FilteredElementCollector familyInstanceCollector = 
  new FilteredElementCollector(doc);

familyInstanceCollector.OfClass(typeof(FamilyInstance))
  .WherePasses(new FamilySymbolFilter(new ElementId(140519)));

MessageBox.Show(familyInstanceCollector.Count<Element>().ToString());

foreach (Element element in familyInstanceCollector)
  MessageBox.Show(element.Name);

【问题讨论】:

    标签: revit revit-api


    【解决方案1】:

    我不确定创建这样的新 ElementId 是否可行,而且我不确定您是否可以跨项目预测 ElementId?最好的方法是进行过滤以搜索您所在的家庭符号先查找,然后使用该结果查找实例。

    查看 SDK 中的 .chm 文件,这是其中的一个示例:

    // Creates a FamilyInstance filter for elements that are family instances of the given    family symbol in the document
    
    // Find all family symbols whose name is "W10X49"
    FilteredElementCollector collector = new FilteredElementCollector(document);
    collector = collector.OfClass(typeof(FamilySymbol));
    
    // Get Element Id for family symbol which will be used to find family instances
    var query = from element in collector where element.Name == "W10X49" select element;
    List<Element> famSyms = query.ToList<Element>();
    ElementId symbolId = famSyms[0].Id;
    
    // Create a FamilyInstance filter with the FamilySymbol Id
    FamilyInstanceFilter filter = new FamilyInstanceFilter(document, symbolId);
    
    // Apply the filter to the elements in the active document
    collector = new FilteredElementCollector(document);
    ICollection<Element> familyInstances = collector.WherePasses(filter).ToElements();
    

    【讨论】:

      猜你喜欢
      • 2020-08-29
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-29
      • 2015-04-04
      相关资源
      最近更新 更多