Skip to content

New Tool - Diagnose Invisibility - #3600

Open
Wurschdhaud wants to merge 3 commits into
pyrevitlabs:developfrom
Wurschdhaud:tool-diagnose-invis
Open

New Tool - Diagnose Invisibility#3600
Wurschdhaud wants to merge 3 commits into
pyrevitlabs:developfrom
Wurschdhaud:tool-diagnose-invis

Conversation

@Wurschdhaud

Copy link
Copy Markdown
Contributor

Description

A new tool, Diagnose Invisibility, that explains why an element isn't
showing up in a view — instead of leaving you to click through Visibility
Graphics, worksets, filters, and view range by hand.

Select (or pick) one or more elements, pick one or more views, and it prints
a report per view listing, for every element, either "visible" or the exact
reason(s) it isn't.

image

Why

"Why can't I see this thing" is one of the most common Revit support
questions, and the answer is almost never just one setting. This walks
through every mechanism that can hide an element in a view, in order, and
reports every one that applies rather than stopping at the first hit.

Checks performed

  • Workset hidden / closed / hidden by the model's default visibility setting
  • Phase filter (via the element's real PhaseStatus, not raw sequence numbers)
  • Design option mismatch
  • Category / subcategory hidden in the view
  • Element explicitly hidden (Hide/Isolate)
  • View filters that override visibility off
  • Crop region (2D) and active 3D section box
  • View range, including the view depth plane (plan views)
  • View template applied (informational — settings may be locked)
  • View-specific elements (detail items/annotations) owned by another view
  • View discipline (informational — Revit auto-hides some categories per
    discipline, e.g. certain structural/MEP-only or architectural-only
    categories, independent of Visibility/Graphics)

Usage

  1. Select element(s) beforehand, or run with nothing selected to be prompted
    to pick them.
  2. Pick one or more views from the list.
  3. Read the report — each element is a clickable link that selects it back
    in the model; each reason is spelled out in plain language.

Checklist

Before submitting your pull request, ensure the following requirements are met:

  • Code follows the PEP 8 style guide.
  • Code has been formatted with Black using the command:
    pipenv run black {source_file_or_directory}
  • Changes are tested and verified to work as expected.

@Wurschdhaud Wurschdhaud added the Tools Issues related to pyRevit commands [subsystem] label Aug 29, 2026
@jmcouffin
jmcouffin requested a balanced review from Copilot September 4, 2026 06:59
@pyrevitlabs pyrevitlabs deleted a comment from devloai Bot Sep 4, 2026

@devloai devloai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tool — this is exactly the kind of "why can't I see this" pain that deserves automation, and the breadth of checks (workset, phase status via the real API, design option, filters via PassesFilter, section box in local coordinates, RCP-aware view range, etc.) is genuinely well thought out.

Two things worth a look before merge:

  1. The visible_ids fast-path (via FilteredElementCollector(doc, view.Id)) isn't a reliable "definitely visible" signal for crop-region/section-box clipping per Revit API docs — it can short-circuit past the dedicated crop/section-box checks and report "Visible" for elements that are actually clipped out.
  2. The pick_prompt localized string (translated into 8 languages!) is never wired up to revit.pick_elements().

Neither is a showstopper, but the crop-box one directly affects report accuracy for a very common scenario.

Suggestions

  • Run crop/section-box checks even when collector says visible Apply
  • Wire pick_prompt into revit.pick_elements() call Apply

visible_ids = set(
get_elementid_value(e.Id) for e in query.get_all_elements_in_view(view)
)
if eid in visible_ids:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FilteredElementCollector(doc, view.Id) is not a reliable "is actually visible" test for crop/section-box clipping. Per the Revit API docs remarks for the view-scoped collector constructor:

"For elements which are outside of a crop region, they may still be passed by the collector because Revit relies on later processing to eliminate the elements hidden by the crop... You can compare the boundary of the region with the element's boundary if more precise results are required."

So an element sitting entirely outside the crop region or an active 3D section box can still show up in visible_ids, causing this function to early-return [], [] ("Visible") here — before the dedicated crop-box/section-box checks (8a/8b) below ever run. Since "why isn't this outside my crop region visible" is a very common real-world case, this short-circuit can silently produce a wrong "Visible" verdict for exactly the scenario this tool is meant to diagnose.

Consider running the crop/section-box bbox checks even when the element is in visible_ids, or moving the fast-path check after those geometric checks.

actions

Feedback: Rate this comment to help me improve future code reviews:

  • 👍 Good - Helpful and accurate
  • 👎 Poor - Wrong, unclear, or unhelpful
  • Skip if you don't have any strong opinions either way.

selection = revit.get_selection()
if selection and len(selection) > 0:
return list(selection.elements)
elements = revit.pick_elements()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pick_prompt string (translated into all 8 locales in the resource dictionaries) is never actually used — revit.pick_elements() is called with no message, so the status-bar prompt falls back to pyRevit's default instead of the localized "Select element(s) to diagnose".

Suggested change
elements = revit.pick_elements()
elements = revit.pick_elements(message=_t("pick_prompt", "Select element(s) to diagnose"))
actions

Feedback: Rate this comment to help me improve future code reviews:

  • 👍 Good - Helpful and accurate
  • 👎 Poor - Wrong, unclear, or unhelpful
  • Skip if you don't have any strong opinions either way.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It is a large, self-contained new IronPython tool relying on many Revit visibility APIs that can only be validated by running inside Revit, which is beyond automated verification here.

Pull request overview

This PR adds a new pyRevit tool, Diagnose Invisibility, under Analysis.panel > Inspect.pulldown. Given one or more selected/picked elements and one or more chosen views, it prints a per-view, per-element report stating either that the element is visible or the specific reason(s) it is hidden. The diagnosis walks through every Revit mechanism that can hide an element (workset, phase filter, design option, category/subcategory, explicit hide, view filters, crop region, 3D section box, view range/clip planes, view template, view-specific ownership, and view discipline), reporting all applicable causes rather than stopping at the first. UI strings and hidden-reason messages are localized via sibling ResourceDictionary XAML files read through applocales.get_locale_string_from_xaml.

Changes:

  • New script.py implementing the visibility-diagnosis logic and the UI entry point (selection/pick → view selection → localized Markdown report with clickable links).
  • New bundle.yaml with localized title/tooltip for eight languages.
  • Eight resources.ResourceDictionary.<locale>.xaml files providing localized UI strings and reason messages.
File summaries
File Description
.../Diagnose Invisibility.pushbutton/script.py Core diagnosis logic and UI entry point; iterates checks and prints localized per-element reasons
.../Diagnose Invisibility.pushbutton/bundle.yaml Button title/tooltip localized for 8 locales
.../resources.ResourceDictionary.en_us.xaml English UI/reason strings (fallback locale)
.../resources.ResourceDictionary.de_de.xaml German translations
.../resources.ResourceDictionary.fr_fr.xaml French translations
.../resources.ResourceDictionary.es_es.xaml Spanish translations
.../resources.ResourceDictionary.pt_br.xaml Brazilian Portuguese translations
.../resources.ResourceDictionary.ru.xaml Russian translations
.../resources.ResourceDictionary.ko.xaml Korean translations
.../resources.ResourceDictionary.chinese_s.xaml Simplified Chinese translations
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

selection = revit.get_selection()
if selection and len(selection) > 0:
return list(selection.elements)
elements = revit.pick_elements()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tools Issues related to pyRevit commands [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants