ParameterFilterElement Class

Admits elements that satisfy two conditions:
  1. The element's category must be one of a certain set of allowed categories.
  2. The element must pass a series of filter rules.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: (
Since: 2011


public class ParameterFilterElement : FilterElement
Visual Basic
Public Class ParameterFilterElement _
	Inherits FilterElement
Visual C++
public ref class ParameterFilterElement : public FilterElement


Copy C#
public static void CreateViewFilter(Document doc, View view)
      List<ElementId> categories = new List<ElementId>();
      categories.Add(new ElementId(BuiltInCategory.OST_Walls));
      List<FilterRule> filterRules = new List<FilterRule>();

      using (Transaction t = new Transaction(doc, "Add view filter"))

          // Create filter element assocated to the input categories
          ParameterFilterElement parameterFilterElement = ParameterFilterElement.Create(doc, "Example view filter", categories);

          // Criterion 1 - wall type Function is "Exterior"
          ElementId exteriorParamId = new ElementId(BuiltInParameter.FUNCTION_PARAM);
          filterRules.Add(ParameterFilterRuleFactory.CreateEqualsRule(exteriorParamId, (int)WallFunction.Exterior));

          // Criterion 2 - wall height > some number
          ElementId lengthId = new ElementId(BuiltInParameter.CURVE_ELEM_LENGTH);
          filterRules.Add(ParameterFilterRuleFactory.CreateGreaterOrEqualRule(lengthId, 28.0, 0.0001));

          // Criterion 3 - custom shared parameter value matches string pattern
          // Get the id for the shared parameter - the ElementId is not hardcoded, so we need to get an instance of this type to find it
          Guid spGuid = new Guid("96b00b61-7f5a-4f36-a828-5cd07890a02a");
          FilteredElementCollector collector = new FilteredElementCollector(doc);
          Wall wall = collector.FirstElement() as Wall;

          if (wall != null)
              Parameter sharedParam = wall.get_Parameter(spGuid);
              ElementId sharedParamId = sharedParam.Id;

              filterRules.Add(ParameterFilterRuleFactory.CreateBeginsWithRule(sharedParamId, "15.", true));

          ElementFilter elemFilter = CreateElementFilterFromFilterRules(filterRules);

          // Apply filter to view
          view.SetFilterVisibility(parameterFilterElement.Id, false);
Public Shared Sub CreateViewFilter(doc As Document, view As View)
      Dim categories As New List(Of ElementId)()
      categories.Add(New ElementId(BuiltInCategory.OST_Walls))
      Dim filterRules As New List(Of FilterRule)()

      Using t As New Transaction(doc, "Add view filter")

          ' Create filter element assocated to the input categories
          Dim parameterFilterElement__1 As ParameterFilterElement = ParameterFilterElement.Create(doc, "Example view filter", categories)

          ' Criterion 1 - wall type Function is "Exterior"
          Dim exteriorParamId As New ElementId(BuiltInParameter.FUNCTION_PARAM)
          filterRules.Add(ParameterFilterRuleFactory.CreateEqualsRule(exteriorParamId, CInt(WallFunction.Exterior)))

          ' Criterion 2 - wall height > some number
          Dim lengthId As New ElementId(BuiltInParameter.CURVE_ELEM_LENGTH)
          filterRules.Add(ParameterFilterRuleFactory.CreateGreaterOrEqualRule(lengthId, 28.0, 0.0001))

          ' Criterion 3 - custom shared parameter value matches string pattern
          ' Get the id for the shared parameter - the ElementId is not hardcoded, so we need to get an instance of this type to find it
          Dim spGuid As New Guid("96b00b61-7f5a-4f36-a828-5cd07890a02a")
          Dim collector As New FilteredElementCollector(doc)
          Dim wall As Wall = TryCast(collector.FirstElement(), Wall)

          If wall IsNot Nothing Then
              Dim sharedParam As Parameter = wall.Parameter(spGuid)
              Dim sharedParamId As ElementId = sharedParam.Id

              filterRules.Add(ParameterFilterRuleFactory.CreateBeginsWithRule(sharedParamId, "15.", True))
          End If

      ' We use a LogicalAndFilter containing one ElementParameterFilter
      ' for each FilterRule. We could alternatively create a single
      ' ElementParameterFilter containing the entire list of FilterRules.
      Dim elemFilters As New List(Of ElementFilter)()
      For Each filterRule As FilterRule In filterRules
         Dim elemParamFilter As New ElementParameterFilter(filterRule)
      Dim elemFilter As New LogicalAndFilter(elemFilters)

      ' Apply filter to view
          view.SetFilterVisibility(parameterFilterElement__1.Id, False)
      End Using
  End Sub

Inheritance Hierarchy

See Also