diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/ReValueWindow.xaml b/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/ReValueWindow.xaml
index ac5007e29..a05eeffbb 100644
--- a/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/ReValueWindow.xaml
+++ b/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/ReValueWindow.xaml
@@ -15,8 +15,26 @@
Height="24"
SelectionChanged="on_param_change"/>
+
+
+
+ By Format
+
+ Specify the existing pattern of the values in the first box and a new format in the second box. For example,
+ if value is "OVERALL 1ST FLOOR", the first box can contain "{type} {lvl}ST {name}".
+ The tool will match the specified format to the value and will extract the parts accordingly. Using the second box,
+ you can rearrange these extracted parts. In this example, specifying "LEVEL {lvl} - {type} {name} PLAN"
+ inside the second box will revalue to "LEVEL 1 - OVERALL FLOOR PLAN"
+
+
+ By Regular Expression
+
+ If the first box does not contain a format finder "{}", then the tool works in Find/Replace mode with Regular Expression support.
+
+
+
- Original Format:
+ Original Pattern:
- New Format:
+ New Pattern:
diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/script.py b/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/script.py
index 623fcf5a7..955b875c6 100644
--- a/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/script.py
+++ b/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit2.stack/ReValue.pushbutton/script.py
@@ -1,5 +1,7 @@
"""Reformat parameter string values (Super handy for renaming elements)"""
#pylint: disable=E0401,W0703,W0613
+import re
+
from pyrevit import coreutils
from pyrevit import revit, DB
from pyrevit import forms
@@ -17,15 +19,23 @@ def __init__(self, eid, oldvalue, final=False):
self.final = final
self.tooltip = ''
- def format_value(self, old_format, new_format):
+ def format_value(self, from_pattern, to_pattern):
try:
- if old_format and new_format:
- self.newvalue = coreutils.reformat_string(self.oldvalue,
- old_format,
- new_format)
- self.tooltip = '{} --> {}'.format(old_format, new_format)
+ if from_pattern and to_pattern:
+ # if format contains pattern finders use reformatter
+ if any(x in from_pattern for x in ['{', '}']):
+ self.newvalue = \
+ coreutils.reformat_string(self.oldvalue,
+ from_pattern,
+ to_pattern)
+ self.tooltip = '{} --> {}'.format(from_pattern, to_pattern)
+ # otherwise use a simple find/replacer
+ else:
+ self.newvalue = \
+ re.sub(from_pattern, to_pattern, self.oldvalue)
else:
self.tooltip = 'No Conversion Specified'
+ self.newvalue = ''
except Exception:
self.newvalue = ''