Latest news
TutorialsRevit

Revit API View Filters: A Guide to Creating and Managing Them

Revit API view filters can sort elements by category and parameter rules, or by selected element IDs. This guide explains how to create filters, apply them to views, and manage visibility and graphic settings.

A bright, minimalist design studio with architectural drawings that use color to distinguish different elementsAI image
Representative image, generated with AI.Image: 3dsınıfı / FCA AI

In brief

  1. ParameterFilterElement works with categories and one or more rules.
  2. SelectionFilterElement uses element IDs added to the filter rather than rules.
  3. View.SetFilterVisibility() controls visibility, while View.SetFilterOverrides() manages graphic settings.
  4. In Revit 2024, ElementId’s internal storage changed to 64-bit; some code compiled against the older API may need to be recompiled.

What will you learn in this guide?

In the Revit API, view filters can be used to control which elements appear in a view or how they look. This guide covers two types of filters: ParameterFilterElement, which uses category and parameter conditions, and SelectionFilterElement, which consists of specific element IDs. We’ll walk through creating a filter, adding it to a view, changing visibility, and applying graphic settings.

In architectural documentation, this approach can be used, for example, to hide walls that meet specific conditions or distinguish selected elements with a different line color. These are illustrative scenarios; the categories and rules used should be determined by the project’s needs.

Requirements and version checks

This guide is for developing plugins with the Revit API; it is not a menu-by-menu guide to the Revit user interface. The API documentation referenced here covers creating and working with filters in a Revit document and view. No specific account type, fee, or additional hardware requirement is stated.

It’s important to use the API documentation for your target Revit version. Autodesk’s Revit 2024 API documentation notes that developers can refer to the RevitAPI.chm help file and the Samples\SDKSamples.sln solution included with the SDK. Don’t assume that code written for an older version will work unchanged in a newer one.

For example, in Revit 2024, the internal storage for ElementId changed from 32-bit to 64-bit. The Value property, which returns the full 64-bit value, replaced the previous IntegerValue property. Autodesk reports that code compiled against earlier API versions may encounter some type-conversion issues and should be recompiled against the Revit 2024 API. When developing filters, check the documentation for the classes and methods in your target version.

Step by step: creating a parameter filter

  1. Choose categories and conditions. ParameterFilterElement uses one or more permitted categories and rules to apply to elements in those categories. Before creating the filter, decide which elements it should cover and which parameter values it should target. Autodesk’s example selects the Walls category; its rules include a wall function of “Exterior” and a length value equal to or greater than a specified threshold.

  2. Create the filter element and assign its rules. ParameterFilterElement.Create creates the filter element using the document, filter name, and category list. Once the rules are ready, assign them with SetRules. The source demonstrates conditions for equality, greater than or equal to a threshold, and text beginning with a specified string. These examples don’t mean that the same parameters should be used in every project; each rule must be compatible with the relevant categories and parameters.

  3. Associate the filter with a view. View.AddFilter() applies the filter to the target view. However, this call uses the default graphic overrides, so the filter may have no visible effect. Treat the presence of a filter and how it appears in a view as separate concerns.

  4. Set visibility. View.SetFilterVisibility() determines whether elements matching the filter conditions are visible. If the filter hasn’t already been applied to the view, this method also adds it, so a separate AddFilter() call isn’t required. For example, if the goal is to hide matching elements, set visibility accordingly.

  5. Apply graphic settings. Use View.SetFilterOverrides() to change view properties, such as the line color, of elements matching the filter. Retrieve the current settings with View.GetFilterOverrides(). This allows filters to be used not only to control visibility, but also to visually distinguish elements in a view.

Step by step: selection filters and editing filters

  1. Identify the elements to include. SelectionFilterElement works with the IDs of a group of elements rather than parameter rules. In the source example, room tags in a specific view are collected first, then the IDs of tags that meet a room-number condition are added to a list. With this method, the filter’s scope is determined by the selected element IDs, not by filter rules.

  2. Create the selection filter. Create the filter element with SelectionFilterElement.Create, then assign the element IDs to it with SetElementIds. Add the filter ID to the target view using View.AddFilter(). Checking that the correct elements were collected can help prevent unexpected results.

  3. Optionally add a graphic override. In Autodesk’s example, the existing filter settings in the view are retrieved, the line color is set to blue, and the result is applied with View.SetFilterOverrides(). This demonstrates how to add a graphic setting to a selection filter; choose the color and other visual preferences according to project standards.

  4. Review existing filters. View.GetFilters() returns the filter IDs in a view. Inspect a specific filter’s visibility with View.GetFilterVisibility() and its graphic settings with View.GetFilterOverrides(). View.RemoveFilter() removes a filter from the view. To change existing settings, first read the filter values, then apply the appropriate graphic settings with View.SetFilterOverrides().

In Autodesk’s examples, operations that modify the document are performed inside a transaction. Keep in mind that creating a filter, associating it with a view, and changing graphic settings all modify the document. Checking each function separately makes it easier to determine whether an issue is caused by a filter rule, visibility, or graphic settings.

Common issues and next steps

The filter was added, but the view hasn’t changed: AddFilter() uses the default graphic settings and may not produce a visible change on its own. Check SetFilterVisibility() for visibility and SetFilterOverrides() for graphic differences.

The rule isn’t finding the expected elements: Review the filter’s permitted categories and the parameters used in its conditions. Because a parameter filter is restricted by category, elements in categories outside its scope won’t be included, even if they match the rule.

The selection filter includes the wrong elements: Inspect the ID list created before SetElementIds and the selection conditions used to generate it. This filter type doesn’t apply parameter rules automatically; the IDs of the target elements must be assigned to the filter explicitly.

The plugin has issues in another Revit version: Check the API changes for the target version. The 64-bit ElementId change in Revit 2024 may require code compiled against an older API to be recompiled. Before development or an update, test in a view set aside for that purpose and match the API documentation you use to the relevant version.

For architecture, interior design, and visualization teams, filters can be useful when element groups in views need to be managed consistently. A parameter filter defines criteria through categories and rules, while a selection filter focuses directly on specified groups of elements. The right choice depends on the view standard and how elements are selected. Plugin compatibility and version transitions should also be considered as part of the workflow.

When you start implementing filters, begin with a small test view: keep the scope narrow, then verify filter matches, visibility, and graphic settings separately. Once the results behave as expected, adapt the approach to your project standards.

Sources and license

This guide is based on the “View Filters” section of Autodesk’s Revit API Developers Guide and Autodesk’s help content on Revit 2024 API changes. The sources are freely accessible according to the license information provided; this article is a Turkish adaptation of the technical explanations in those sources.

Sources

2 sources
H
help.autodesk.comhelp.autodesk.com/cloudhelp/2018/ENU/Revit-API/Revit_API_Developers_Guide/Basic_Interaction_with_Revit_Elements/Views/View_Filters.html
Summary
H
help.autodesk.comhelp.autodesk.com/view/RVT/2024/ENU
Summary

Source texts are not republished; short quotes are marked, everything else is our own summary and commentary.

3dsınıfı’s take
3dEditor’s assessment

Revit API filters can help offices manage element groups in views more systematically. Parameter-based rules are useful for recurring situations, while a selection filter offers a way to limit the scope to explicitly specified elements.

The sources provide no pricing or licensing information for offices and students in Turkey, so these factors should be researched separately when making a decision. One practical consideration is version compatibility: Revit API changes can affect older plugins. Testing filters and the plugin in the target version before using production files is a more cautious approach.

Frequently asked questions

How do you create a parameter filter in the Revit API?

Use `ParameterFilterElement.Create` to define the category scope, prepare the filter rules, and assign them with `SetRules`. You can then associate the filter with a view and set its visibility and graphic settings.

What’s the difference between a selection filter and a parameter filter in the Revit API?

A parameter filter works through categories and rules. A selection filter uses the element IDs added to it rather than evaluating rules.

Does the Revit 2024 API change affect older plugins?

In Revit 2024, `ElementId` storage changed to 64-bit, and the `Value` property replaced `IntegerValue`. Autodesk notes that some code compiled against earlier APIs may encounter type issues and may need to be recompiled against the Revit 2024 API.

Comments and the forum are in Turkish.Join the discussion
+

Related news