using Autodesk.Revit.DB; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FWindSoft.Revit { public static class DocumentExtension { #region 过滤 public static List GetElements(this Document doc, ElementFilter filter) { var collector = new FilteredElementCollector(doc); return collector.WherePasses(filter).ToList(); } public static List GetElements(this Document doc) where T : Element { var collector = new FilteredElementCollector(doc); collector.OfClass(typeof(T)); return collector.OfType().ToList(); } public static List GetElementTypes(this Document doc, ElementFilter filter) where T : ElementType { var collector = new FilteredElementCollector(doc); collector.WherePasses(filter); collector.WhereElementIsElementType(); collector.OfClass(typeof(T)); return collector.OfType().ToList(); } #endregion public static ElementType GetElementType(this Document doc, string typeName) { var types = doc.GetElements(); return types.FirstOrDefault(type => type != null && type.Name == typeName); } } }