Diagnose Invisibility - Phase Filter GetPhaseStatusPresentation

I am trying to build a tool, helping users to identify why an element is visible in one view, but not the other. The most common reasons are easy, like closed/hidden workset, wrong design option, filters applied, category hidden etc. But I am struggling with the phase filter check.

I found, or an LLM did, the right API command, but unfortunately there is no sample in the Revit SDK on how to use it, and google has exactly one hit in the autodesk forums. Does anyone have an idea?

    view_phase_param = view.get_Parameter(DB.BuiltInParameter.VIEW_PHASE)
    view_phase_id = (
        view_phase_param.AsElementId()
        if view_phase_param else DB.ElementId.InvalidElementId
    )

    if view_phase_id and view_phase_id != DB.ElementId.InvalidElementId:
        try:
            phase_status = element.GetPhaseStatus(view_phase_id)
            # ElementOnPhaseStatus.None means the element has no phase data
            # and is not subject to phase filtering.
            if phase_status != getattr(DB.ElementOnPhaseStatus, 'None'):
                pf_param = view.get_Parameter(DB.BuiltInParameter.VIEW_PHASE_FILTER)
                pf_id = pf_param.AsElementId() if pf_param else DB.ElementId.InvalidElementId
                if pf_id and pf_id != DB.ElementId.InvalidElementId:
                    phase_filter = doc.GetElement(pf_id)
                    if phase_filter:
                        # TODO FIXME this for whatever reason doesn't work. API seems to be
                        # the right one according to docs.
                        # Errorcode is 'status is invalid for presentation query.' Printing
                        # 'phase_status' yields a correct ElementOnPhaseStatus.
                        # No Samples for this API found in SDK samples. Only web reference:
                        # https://forums.autodesk.com/t5/revit-api-forum/elements-project-phase-and-view-visibility/td-p/10566524
                        presentation = phase_filter.GetPhaseStatusPresentation(phase_status)
                        if presentation == DB.PhaseStatusPresentation.DontShow:
                            reasons.append(
                                "Hidden by phase filter"
                                " (element phase status: '{}')".format(phase_status)
                            )
                            reasons_short.append("Phase Filter")
        except Exception as e:
            print(e)
            pass

Being extremely lazy and not in front of a computer, I ask Claude for an example based on the apidocs article…

PhaseFilter.GetPhaseStatusPresentation

This method lets you query how a PhaseFilter displays elements that have a given phase status (e.g. New, Existing, Demolished, Temporary).


What it does

Given an ElementOnPhaseStatus, it returns the corresponding PhaseStatusPresentation – telling you whether elements with that status are shown, shown as grayed, or hidden by the filter.


Usage (Python/pyRevit)

from Autodesk.Revit.DB import (
    FilteredElementCollector,
    PhaseFilter,
    ElementOnPhaseStatus,
    ElementId
)

doc = __revit__.ActiveUIDocument.Document

# Get a PhaseFilter from the document
phase_filters = FilteredElementCollector(doc)\
    .OfClass(PhaseFilter)\
    .ToElements()

pf = phase_filters[0]  # or find the one you need by name

# Query the presentation for each phase status
statuses = [
    ElementOnPhaseStatus.New,
    ElementOnPhaseStatus.Existing,
    ElementOnPhaseStatus.Demolished,
    ElementOnPhaseStatus.Temporary,
]

for status in statuses:
    presentation = pf.GetPhaseStatusPresentation(status)
    print(f"{status}: {presentation}")

Key types

Type Description
ElementOnPhaseStatus The phase status of an element (New, Existing, Demolished, Temporary)
PhaseStatusPresentation How it’s shown: Show, Overridden, or DoNotShow

Practical use case

Useful when you need to understand or replicate the visibility logic of a phase filter – for example, checking whether “Demolished” elements are hidden or shown with overrides in a given view’s active phase filter.

To get the phase filter applied to a view:

from Autodesk.Revit.DB import BuiltInParameter

view = doc.ActiveView
pf_id = view.get_Parameter(BuiltInParameter.VIEW_PHASE_FILTER).AsElementId()
pf = doc.GetElement(pf_id)

presentation = pf.GetPhaseStatusPresentation(ElementOnPhaseStatus.Demolished)
print(presentation)  # e.g. PhaseStatusPresentation.DoNotShow

Not sure if your team/firm uses Ideate Software, but it has an “XRAY” mode specifically for this. Just thought I’d share.

1 Like

Thanks for hint with Ideate! Unfortunately we don’t use it.

Also the issue resolved itself over night. Absolutely no clue why, but the code above works in case anyone has a similiar issue :smiley:

1 Like