Enhance font replacement functionality in Revit families#2723
Enhance font replacement functionality in Revit families#2723
Conversation
- Added regex support for case-insensitive font name replacement. - Implemented recursive updates for nested generic annotation families. - Improved error handling and logging during font updates. - Updated main script logic to handle font replacement in both family and project documents.
There was a problem hiding this comment.
PR Summary:
This PR enhances the font replacement functionality by adding:
• Regex support for case-insensitive font name replacement
• Recursive updates for nested generic annotation families
• Improved error handling and logging during font updates
• Support for both family and project document font replacement workflows
Review Summary:
I've identified several critical issues that need to be addressed before merging. The main concerns are: a document resource leak risk in nested family processing, Revit API compatibility issues with ElementId changes in newer versions, and a variable scope bug in exception handling. I utilized my knowledge of pyRevit's coding standards and Revit API version compatibility requirements to perform this review. Please provide feedback on this review which I'll incorporate for future reviews.
Follow-up suggestions:
• @devloai fix the identified issues in this PR
• @devloai add error recovery mechanisms for family loading failures
...ension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py
Outdated
Show resolved
Hide resolved
...ension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py
Outdated
Show resolved
Hide resolved
...ension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py
Outdated
Show resolved
Hide resolved
...ension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py
Show resolved
Hide resolved
…t3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py Co-authored-by: devloai[bot] <168258904+devloai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the font replacement script for Revit families by adding regex-based, case-insensitive renaming and recursive updates for nested generic annotation families, along with improved error handling and updated main logic to support both family and project documents.
- Add
rename_element_type_if_neededfor regex-based, case-insensitive font name replacement. - Implement recursive traversal and updating of nested generic annotation families.
- Improve error logging and expand main script to handle both family and project contexts.
Comments suppressed due to low confidence (2)
extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py:3
- The code calls
FamilyLoaderOptionsHandlerbut it isn’t imported. Add an import, for example:from rpw import FamilyLoaderOptionsHandler(or the appropriate module) to prevent a NameError.
import re
extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py:32
- Using
DB.Element.Name.GetValueandSetValueis nonstandard and may not work. It’s clearer and more reliable to use the ElementType’sNameproperty directly, e.g.,current_name = element_type.Nameandelement_type.Name = new_name.
current_name = DB.Element.Name.GetValue(element_type)
...ension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py
Outdated
Show resolved
Hide resolved
…t3.stack/Edit.pulldown/Replace_Fonts.pushbutton/script.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25183+0806-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25189+0609-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25204+0748-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25209+2004-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25211+1247-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25213+1402-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1027-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25216+1429-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+0909-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1354-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1400-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1405-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25219+1421-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25220+1008-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25225+0806-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25225+1628-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25240+1743-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25243+1636-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25243+1639-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25244+0918-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+0639-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+0642-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25245+1846-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25246+0855-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25248+0948-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0758-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0805-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25251+0824-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25252+1659-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0644-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25255+0911-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25256+0727-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25258+1448-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25265+1047-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25266+0803-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25268+1757-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1336-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1431-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1436-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25269+1822-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25271+1719-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2003-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2012-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2017-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25272+2149-wip |
|
📦 New work-in-progress (wip) builds are available for 5.2.0.25302+0949-wip |
Description
thanks to https://discourse.pyrevitlabs.io/u/denver-22 🚀
Checklist
Before submitting your pull request, ensure the following requirements are met:
Related Issues
https://discourse.pyrevitlabs.io/t/font-replacement-suggested-changes/9216