Skip to content

Conversation

@Wurschdhaud
Copy link
Contributor

Description

This PR introduces new helper functions restore_window_position() and save_window_position() to simplify persistent window positioning across pyRevit sessions. These functions encapsulate the common pattern of storing/restoring window coordinates with screen visibility validation.

Implemented in "measure 3d" for testing.

Question for reviewers: Are there better or more Windows-native solutions for handling window position persistence that I should be aware of? I'm not familiar with alternatives beyond this approach.


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.

Related Issues

If applicable, link the issues resolved by this pull request:

  • Resolves #[issue number]

Additional Notes

  • Validates saved positions are visible on current screen configuration
  • Falls back to center screen if saved position is invalid or off-screen
  • Uses existing script.load_data() / script.store_data() infrastructure

Thank you for contributing to pyRevit! 🎉

@devloai
Copy link
Contributor

devloai bot commented Nov 30, 2025

Unable to perform a code review. You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

@jmcouffin jmcouffin requested a review from Copilot November 30, 2025 16:58
Copilot finished reviewing on behalf of jmcouffin November 30, 2025 17:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces reusable helper functions restore_window_position() and save_window_position() to standardize window position persistence across pyRevit tools. The pattern is demonstrated by refactoring the "Measure 3D" tool to use these new utilities instead of inline position management code.

Key changes:

  • Added restore_window_position() and save_window_position() helper functions in pyrevit/script.py
  • Refactored Measure 3D tool to use new helper functions, removing ~20 lines of duplicated code
  • Removed unused System import from Measure tool

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pyrevitlib/pyrevit/script.py Added two new helper functions for window position persistence with screen visibility validation
extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/3D.pulldown/Measure.pushbutton/script.py Refactored to use new helper functions, removing inline window position management code and unused import

- store width+height
- reuse coreutils function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant