Skip to content

Door flip state #2663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Conversation

mangrove-art
Copy link
Contributor

@mangrove-art mangrove-art commented May 1, 2025

Door flip state

Description

This script writes the mirror state (aka Left/Right) of doors back to an instance parameter 'Door Wing Opening Direction' in doors.


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.

Thank you for contributing to pyRevit! 🎉

Copy link
Contributor

@devloai devloai bot left a comment

Choose a reason for hiding this comment

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

PR Summary:

This PR adds a new script for analyzing and updating door mirror states. It writes the mirror state (Left/Right) of doors to an instance parameter called 'Door Wing Opening Direction'. The script identifies mirrored vs. standard door configurations and updates a parameter that can be used for documentation or scheduling. It includes thorough error handling for doors without the required parameters and provides a detailed report of changes made.

Review Summary:

The code successfully implements the intended functionality but contains a few critical issues that should be addressed. The most significant concern is calling sys.exit() within a transaction, which could leave the document in an inconsistent state. There are also some empty exception handlers that make debugging difficult, and a performance optimization opportunity with repeated parameter lookups. Feel free to provide feedback on this review for future improvements.

Follow-up suggestions:

@devloai fix the transaction handling to ensure the document remains in a consistent state

@jmcouffin jmcouffin requested a review from Copilot May 2, 2025 05:37
Copy link
Contributor

@Copilot 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 adds a script that writes the mirror state of doors back to an instance parameter and updates the corresponding bundle metadata.

  • Implements a new script (script.py) to update door mirror state via shared parameters.
  • Updates the bundle.yaml with multilingual labels and tooltips for the pushbutton.

Reviewed Changes

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

File Description
script.py Implements door mirror state update logic with shared parameter writebacks and summary reporting.
bundle.yaml Provides multilingual title, tooltip, and author metadata for the pushbutton.
Comments suppressed due to low confidence (1)

extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/script.py:48

  • [nitpick] The error message for a missing parameter is unclear. Consider rephrasing it to: "Please create the instance parameter 'Door Wing Opening Direction' with the option for different values for group instances in the Doors category."
Please create the parameter as an instance parameter, option different values for groupes,

@jmcouffin
Copy link
Contributor

@mangrove-art Cool.
Question:
Do you really need all these parameters?

  • IMO creating parameters within a routine will refrain people to actually use it
  • You would not have to check for parameters existence
  • You could color and isolate in dedicated views: mirrored and inverted doors (and their host walls) each in a different color

If you feel like sticking with the parameters approach, I suggest you use only project parameters and create them while in the script, and have a routine to delete them afterward.

EF and others added 11 commits May 2, 2025 12:56
…ools.stack/Analyse.pulldown/Door Mirror State.pushbutton/script.py

Co-authored-by: devloai[bot] <168258904+devloai[bot]@users.noreply.github.com>
- Black formatting
- Removed unnecessary comments
- Error Handling
- pyrevit module usage instead of Autodesk's
…ools.stack/Analyse.pulldown/Door Mirror State.pushbutton/script.py

Co-authored-by: Copilot <[email protected]>
…ools.stack/Analyse.pulldown/Door Mirror State.pushbutton/bundle.yaml

Co-authored-by: Copilot <[email protected]>
@mangrove-art
Copy link
Contributor Author

@mangrove-art Cool. Question: Do you really need all these parameters?

* IMO creating parameters within a routine will refrain people to actually use it

* You would not have to check for parameters existence

* You could color and isolate in dedicated views:  mirrored and inverted doors (and their host walls) each in a different color

If you feel like sticking with the parameters approach, I suggest you use only project parameters and create them while in the script, and have a routine to delete them afterward.

Actually your thoughts are perfectly right although I cannot follow your advices. Let me explain.

  1. The project parameter called "Door Wing Opening Direction" is used to get the values in schedules, annotations and filters in specific views. I didn't want to missuse a builtin parameter to be explicit in meaning of the acquired information. As a parameter file is provided in the script folder it seems quite easy to create the parameter.

  2. The two parameters called "DoorFamilyOpeningDirection_standard" and "DoorFamilyOpeningDirection_mirrored" reflected for me the easyiest way to deal with different standard door swing directions modelled families in an existing project. They allow a liberty to provide f.ex. the same return value for both states like the case of a sliding door where the swing opening direction is not clearly defined. Also they allow to handle complex situations where a door is part of a panel and both can be mirrord, see image joined.
    Overall it was the most simpliest way to deal with all geometric exeptions for me. I recognize that is not a simple solution to the problem. @jmcouffin What do you think?
    2025-05-02 17_42_57-Familientypen

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.

2 participants