public static ElementFilter GetElementFilter(this ParameterFilterElement parameterFilter) { var filters = new List <ElementFilter>() { new ElementMulticategoryFilter(parameterFilter.GetCategories()) }; foreach (var rule in parameterFilter.GetRules()) { filters.Add(new ElementParameterFilter(rule)); } return(new LogicalAndFilter(filters)); }
private void GatherFilterColorOverride() { if (CurrentDocument == null || CurrentView == null) { return; } ICollection <ElementId> filterIds = null; try { filterIds = CurrentView.GetFilters(); if (filterIds == null || filterIds.Count < 1) { return; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (ElementId idFilter in filterIds) { try { ParameterFilterElement filter = CurrentDocument.GetElement(idFilter) as ParameterFilterElement; if (filter == null) { continue; } OverrideGraphicSettings overrideSettings = CurrentView.GetFilterOverrides(idFilter); if (overrideSettings == null) { continue; } if (!overrideSettings.ProjectionFillColor.IsValid) { continue; } AddMaterial(filter.Name, overrideSettings.ProjectionFillColor); List <ElementId> listElem = new List <ElementId>(); var cids = filter.GetCategories(); if (cids == null) { continue; } foreach (ElementId catID in cids) { FilteredElementCollector collector = (new FilteredElementCollector(CurrentDocument, CurrentView.Id)).OfCategoryId(catID); var lstid = collector.ToElementIds() as List <ElementId>; if (lstid == null) { continue; } listElem.AddRange(lstid); } List <ElementId> elemPassed = new List <ElementId>(); foreach (ElementId elemId in listElem) { if (CanPassFilterRules(filter, elemId)) { elemPassed.Add(elemId); } } foreach (ElementId elemId in elemPassed) { if (!m_dictElemColor.ContainsKey(elemId)) { m_dictElemColor.Add(elemId, filter.Name); } } } catch (Exception) { continue; } } }
/// <summary> /// Initialize from a Filter object. /// </summary> /// <param name="filterElement"></param> public FilterST(ParameterFilterElement filterElement) { Name = filterElement.Name; Categories = filterElement.GetCategories(); FilterRules = filterElement.GetRules().ToList(); }