/// <summary> /// Groups elements in the collector by their name /// </summary> /// <param name="collector">A Collector to search</param> /// <returns name="Elements">Returns a list of lists of Dynamo wrapped elements that are grouped by name</returns> public static List <List <DynElem> > QueryGroupByName(Collector collector) { RevitCollector rCollector = collector._ApplyFilters(); List <List <DynElem> > dynamoElements = rCollector .Cast <RevitDB.Element>() .GroupBy(elem => elem.Name) .Select(grp => grp.Select(elem => elem.ToDSType(true)).ToList()) .ToList(); return(dynamoElements); }
/// <summary> /// Searches the Collector for elements whose Name does not contain the string. /// </summary> /// <param name="collector">A Collector to search</param> /// <param name="name">Name of the elements to find.</param> /// <returns name="Elements">Returns a list of Dynamo wrapped elements that matches the query</returns> public static IList <DynElem> QueryNameDoesNotContain(Collector collector, string name) { RevitCollector rCollector = collector._ApplyFilters(); IList <DynElem> dynamoElements = rCollector .Cast <RevitDB.Element>() .Where(elem => !elem.Name.Contains(name)) .Select(elem => { return(elem.ToDSType(true)); }) .ToList(); return(dynamoElements); }
/// <summary> /// Retrieves the Elements that pass the Collector's filters /// </summary> /// <param name="collector">A Synthetc Collector</param> /// <param name="toggle">Toggle will reset the Dynamo graph and rerun the collector.</param> /// <returns>A</returns> public static IList <DynElem> ToElements(Collector collector, [DefaultArgument("true")] bool toggle = true) { IList <RevitDB.Element> elements = collector._ApplyFilters().ToElements(); IList <DynElem> dynamoElements = new List <DynElem>(); foreach (RevitDB.Element elem in elements) { try { dynamoElements.Add(elem.ToDSType(true)); } catch { } } return(dynamoElements); }
/// <summary> /// Retrieves the ElementIds of elements that pass the Collector's filters. /// </summary> /// <param name="collector">A Syntehtic Collector</param> /// <returns name="ElementIds">Returns the ElementIds of the elements that pass the collector's filters.</returns> public static IList <RevitDB.ElementId> ToElementIds(Collector collector) { return((IList <RevitDB.ElementId>)collector._ApplyFilters().ToElementIds()); }
/// <summary> /// Retrieves the Elements that pass the Collector's filters /// </summary> /// <param name="collector">A Synthetc Collector</param> /// <param name="toggle">Toggle will reset the Dynamo graph and rerun the collector.</param> /// <returns name="Elements">Autodesk.Revit.DB.Elements</returns> public static IList <RevitDB.Element> ToRevitElements(Collector collector, [DefaultArgument("true")] bool toggle = true) { return((List <RevitDB.Element>)collector._ApplyFilters().ToElements()); }
/// <summary> /// Applies filters and returns the Revit FilteredElementCollector object. This object gives quick access to the elements in the collector. /// </summary> /// <param name="collector">A Synthetic Collector object.</param> /// <returns name="Revit Collector">A Revit FilteredElementCollector object.</returns> public static RevitCollector ApplyFilters(Collector collector) { return(collector._ApplyFilters()); }