public static IList <Element> AtLevel(Level arg) { if (arg == null) { return(null); } var levFilter = new Autodesk.Revit.DB.ElementLevelFilter(arg.InternalLevel.Id); var fec = new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); var instances = fec.WherePasses(levFilter) .WhereElementIsNotElementType() .ToElementIds() .Select(id => ElementSelector.ByElementId(id.IntegerValue)) .ToList(); return(instances); }
/// <summary> /// Select Elements by Level and Category. /// </summary> /// <param name="category">Category to filter for.</param> /// <param name="level">Level to filter for.</param> /// <returns name="Element">Elements.</returns> public static IList <Element> ByCategoryAndLevel(Category category, Element level) { var doc = DocumentManager.Instance.CurrentDBDocument; var bic = (Autodesk.Revit.DB.BuiltInCategory)Enum.ToObject(typeof(Autodesk.Revit.DB.BuiltInCategory), category.Id); // create level filter var filter = new Autodesk.Revit.DB.ElementLevelFilter(new Autodesk.Revit.DB.ElementId(level.Id)); // select elements var elements = new Autodesk.Revit.DB.FilteredElementCollector(doc) .OfCategory(bic) .WherePasses(filter) .WhereElementIsNotElementType() .ToElements() .Select(x => x.ToDSType(true)) .ToList(); return(elements.Any() ? elements : Enumerable.Empty <Element>().ToList()); }