Skip to content

[Context] Redraw the Revit interface after the API upgrades a family from an earlier version - #137

Merged
Nice3point merged 7 commits into
developfrom
context/136-rendering-resumption-scope
Oct 31, 2026
Merged

Nice3point merged 7 commits into
developfrom
context/136-rendering-resumption-scope

Conversation

@Nice3point

@Nice3point Nice3point commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary of the Pull Request

What is this about:

Redraws the Revit ribbon, the dockable panes, and the add-in windows after the API upgrades a family from an earlier Revit version.

Description:

What changed

  • RevitContext.BeginModalLoopCompatibilityScope() returns a scope that posts the WPF frame notification MilChannelNotify to the MediaContextNotificationWindow of the current thread on dispose.
  • Every call returns one stateless instance, with no lock, nesting counter, or dispose guard.
  • The scope finds the notification window with FindWindowEx by its title and owner thread, and caches the handle per thread.
  • CsWin32 generates the Win32 interop of the library and the test project from their NativeMethods.txt.
  • The README "Context" section and the changelog describe the scope.

Where to look

  • The scope names two WPF internals: the window title MediaContextNotificationWindow and the registered message MilChannelNotify. Both have the same values in .NET Framework and .NET. If WPF renames them, the scope posts nothing, and the interface behaves as without the scope.
  • The scope departs from the reference counting of the other Begin...Scope() methods: it changes no state. A nested scope and a second dispose post a repeated notification, and WPF reads an empty render channel and returns.
  • The library project suppresses PInvoke009. CsWin32 recommends System.Memory on .NET Framework for Span overloads, and the five functions take no Span. The package takes no new dependency.
  • The test reads the composed frame through PrintWindow. Windows composes no frame for a window entirely outside the screen, so the 40-pixel window shows one column of pixels at the left edge of the virtual screen during the test.

How verified

  • Build: Release.R20, Release.R21, Release.R24, Release.R26, and Release.R27, zero errors and no new warnings.
  • RevitContextTests on Revit 2025 and 2027: 14 passed. On Revit 2026: 15 passed, with the test for a thread without WPF.
  • BeginModalLoopCompatibilityScope_TemplateOfThePreviousVersion_WindowDrawsTheNextFrame creates a family from the installed template of the previous Revit inside the scope. With the post removed, it fails on Revit 2026: the window shows the color of the moment of the upgrade.
  • Not covered: Revit 2021 to 2024 by a test run.

Quality Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@Nice3point Nice3point added bug 🐛 An unexpected issue that highlights incorrect behavior context 🧭 Revit API context, dialog and failure suppression labels Oct 30, 2026
@Nice3point Nice3point self-assigned this Oct 30, 2026
@Nice3point Nice3point changed the title [Context] Resume the rendering of the WPF windows of the Revit thread after a file upgrade [Context] Redraw the Revit interface after the API upgrades a family from an earlier version Oct 31, 2026
@Nice3point
Nice3point changed the base branch from main to develop October 31, 2026 15:31
@Nice3point
Nice3point marked this pull request as ready for review October 31, 2026 15:31
Copilot AI balanced review requested due to automatic review settings October 31, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Nice3point
Nice3point merged commit 3243f78 into develop Oct 31, 2026
1 check passed
@Nice3point
Nice3point deleted the context/136-rendering-resumption-scope branch October 31, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 An unexpected issue that highlights incorrect behavior context 🧭 Revit API context, dialog and failure suppression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WPF windows of the Revit thread stop drawing after the API upgrades a file of an earlier Revit version

2 participants