Skip to content

Copy Sheets to Open Documents: add “Preserve detail numbers” option (default ON), safer param handling, and richer logs#2754

Merged
jmcouffin merged 8 commits intopyrevitlabs:developfrom
czwangxtt:pyr-13
Aug 13, 2025
Merged

Copy Sheets to Open Documents: add “Preserve detail numbers” option (default ON), safer param handling, and richer logs#2754
jmcouffin merged 8 commits intopyrevitlabs:developfrom
czwangxtt:pyr-13

Conversation

@czwangxtt
Copy link
Copy Markdown
Contributor

@czwangxtt czwangxtt commented Aug 11, 2025

Copy Sheets to Open Documents: add “Preserve detail numbers” option (default ON), safer param handling, and richer logs

Description

Extends PR #2704 by making preservation of viewport Detail Number optional. Default is ON to match current behavior. Adds try/except guards to avoid script failure when the parameter is missing, and improves logging for transparency.

Changes

  • Added checkbox: Preserve Detail Numbers (default ON).
  • Wrapped parameter read/write in try/except to prevent transaction rollback.
  • More detailed logs: per-viewport outcome (preserved, renumbered, skipped).

Why

  • Some workflows require fresh numbering instead of preserving originals.
  • Prevents crashes in models where the parameter isn’t available.
  • Clearer feedback during batch copy.

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


Additional Notes

option logs

Add preserve detail number as an option. Make the script more robust. Add more details to the log.
Copy link
Copy Markdown
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 "Preserve Detail Numbers" option (default ON) to the Copy Sheets to Open Documents tool, extending PR #2704. Key changes include:
• New checkbox option for preserving viewport detail numbers
• Enhanced error handling with try/except blocks around parameter operations
• Improved logging with per-viewport outcome messages
• Maintains backward compatibility with default behavior

Review Summary:

The PR successfully implements the requested feature with good intentions for safer parameter handling. However, the parameter access logic contains potential null reference vulnerabilities that could cause runtime failures. The review focused on defensive programming patterns required for robust Revit API parameter handling, drawing from repository standards around exception handling and API safety practices.

Follow-up suggestions:

@devloai fix the identified parameter null reference issues
@devloai consider adding unit tests to validate parameter handling edge cases

Copy link
Copy Markdown
Contributor Author

@czwangxtt czwangxtt left a comment

Choose a reason for hiding this comment

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

Fixed null check and exception handling.

@jmcouffin jmcouffin requested a review from Copilot August 11, 2025 19:33
@jmcouffin jmcouffin added Enhancement Enhancement request [class->Improved #{number}: {title}] Tools Issues related to pyRevit commands [subsystem] labels Aug 11, 2025
Copy link
Copy Markdown
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 enhances the "Copy Sheets to Open Documents" tool by adding a configurable option for preserving viewport detail numbers during sheet copying operations. The enhancement provides users with flexibility to either preserve original detail numbers or allow Revit to assign new ones, while adding robust error handling and improved logging.

  • Added a "Preserve Detail Numbers" checkbox option (defaulting to ON for backward compatibility)
  • Implemented error handling with try/catch blocks to prevent script failures when parameters are unavailable
  • Enhanced logging to provide detailed feedback on viewport processing outcomes

czwangxtt and others added 5 commits August 12, 2025 10:09
…l/Sheets.pulldown/Copy Sheets to Open Documents.pushbutton/script.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…l/Sheets.pulldown/Copy Sheets to Open Documents.pushbutton/script.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…l/Sheets.pulldown/Copy Sheets to Open Documents.pushbutton/script.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@jmcouffin jmcouffin left a comment

Choose a reason for hiding this comment

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

Good to go
thanks

@jmcouffin jmcouffin merged commit 861087d into pyrevitlabs:develop Aug 13, 2025
@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25225+0806-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25225+1628-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25230+1701-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0824-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0848-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+0859-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+1126-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25232+1352-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25233+0639-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25233+1431-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25233+1438-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25237+0821-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25237+0841-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25237+1124-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25265+1047-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25266+0803-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25268+1757-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1336-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1431-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1436-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1822-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25271+1719-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2003-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2012-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2017-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2149-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25274+1734-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1425-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 4, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25277+1427-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 6, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25279+2157-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25280+0218-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25280+1054-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 7, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25280+1057-wip

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 9, 2025

📦 New work-in-progress (wip) builds are available for 5.2.0.25282+1656-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25283+0140-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25286+1022-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25287+0905-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25287+1000-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25288+0613-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25293+0755-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25293+0828-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25293+1113-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25293+1234-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 5.2.0.25302+0949-wip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Enhancement request [class->Improved #{number}: {title}] Tools Issues related to pyRevit commands [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants