diff --git a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.en_us.xaml b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.en_us.xaml
index e2dff24fa..295cf6646 100644
--- a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.en_us.xaml
+++ b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.en_us.xaml
@@ -327,7 +327,7 @@
<current>
<all users>
<Not attached>
- Revit {} <Not installed>
+ <Not installed>
Active engine has changed.
@@ -367,4 +367,4 @@
pyRevit settings are set by your admin.
-
\ No newline at end of file
+
diff --git a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.fr_fr.xaml b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.fr_fr.xaml
index d3bedcf35..338cf6e85 100644
--- a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.fr_fr.xaml
+++ b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.fr_fr.xaml
@@ -315,7 +315,7 @@
<actuel>
<tous les utilisateurs>
<Non attaché>
- Revit {} <Non installé>
+ <Non installé>
Le moteur actif a été modifié.
diff --git a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.ru.xaml b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.ru.xaml
index 442c82665..6080cde86 100644
--- a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.ru.xaml
+++ b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.ResourceDictionary.ru.xaml
@@ -329,7 +329,7 @@
<текущий>
<все пользователи>
<не прикреплен>
- Revit {} <не установлен>
+ <не установлен>
Активный движок изменился.
@@ -369,4 +369,4 @@
Настройки pyRevit устанавливаются вашим администратором.
-
\ No newline at end of file
+
diff --git a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.xaml b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.xaml
index a873f9a58..8e808ffc9 100644
--- a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.xaml
+++ b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/SettingsWindow.xaml
@@ -447,33 +447,18 @@
-
- Autodesk Revit 2025
-
-
- Autodesk Revit 2024
-
-
- Autodesk Revit 2023
-
-
- Autodesk Revit 2022
-
-
- Autodesk Revit 2021
-
-
- Autodesk Revit 2020
-
-
- Autodesk Revit 2019
-
-
- Autodesk Revit 2018
-
-
- Autodesk Revit 2017
-
+
+
+
+
+
+
+
+
diff --git a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/script.py b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/script.py
index 340348f00..62f089328 100644
--- a/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/script.py
+++ b/extensions/pyRevitCore.extension/pyRevit.tab/pyRevit.panel/Settings.smartbutton/script.py
@@ -27,7 +27,7 @@
logger = script.get_logger()
-
+available_revit_versions = ['2025', '2024', '2023', '2022', '2021', '2020', '2019', '2018', '2017']
class EnvVariable(object):
"""List item for an environment variable.
@@ -67,6 +67,15 @@ def name(self):
self.engine.Description)
+class RevitVersionCB:
+ """Represents a Revit version Checkbox for binding with XAML."""
+ def __init__(self, version, is_checked=False, is_enabled=False):
+ self.Content = "Revit {}".format(version) # Display name in the UI
+ self.Version = version # YEAR version (e.g., '2024')
+ self.IsChecked = is_checked # Whether the checkbox is checked
+ self.IsEnabled = is_enabled # Whether the checkbox is enabled
+
+
class SettingsWindow(forms.WPFWindow):
"""pyRevit Settings window that handles setting the pyRevit configs"""
@@ -86,19 +95,9 @@ def __init__(self, xaml_file_name):
self._setup_env_vars_list()
# check boxes for each version of Revit
- # this could be automated but it pushes me to verify and test
- # before actually adding a new Revit version to the list
- self._addinfiles_cboxes = {
- '2017': self.revit2017_cb,
- '2018': self.revit2018_cb,
- '2019': self.revit2019_cb,
- '2020': self.revit2020_cb,
- '2021': self.revit2021_cb,
- '2022': self.revit2022_cb,
- '2023': self.revit2023_cb,
- '2024': self.revit2024_cb,
- '2025': self.revit2025_cb,
- }
+ self.supported_revit_versions_CB = [RevitVersionCB(rvt_ver, is_checked=False, is_enabled=False) for rvt_ver in available_revit_versions]
+ # Bind the SupportedVersions to the XAML's DataContext
+ self.DataContext = self
self.set_image_source(self.lognone, 'lognone.png')
self.set_image_source(self.logverbose, 'logverbose.png')
@@ -372,14 +371,6 @@ def _setup_telemetry(self):
event_checkbox.IsChecked = \
telemetry.get_apptelemetry_event_state(event_flags, event_type)
- def _make_product_name(self, product, note):
- return '_{} | {}({}) {}'.format(
- product.Name,
- product.BuildNumber,
- product.BuildTarget,
- note
- )
-
def _setup_addinfiles(self):
"""Gets the installed Revit versions and sets up the ui"""
installed_revits = \
@@ -389,42 +380,23 @@ def _setup_addinfiles(self):
{str(x.Product.ProductYear):x
for x in PyRevit.PyRevitAttachments.GetAttachments()}
- for rvt_ver, checkbox in self._addinfiles_cboxes.items():
- if rvt_ver in attachments:
- if rvt_ver != HOST_APP.version:
- checkbox.Content = \
- self._make_product_name(
- attachments[rvt_ver].Product,
- ''
- )
- else:
- checkbox.Content = \
- self._make_product_name(
- attachments[rvt_ver].Product,
- self.get_locale_string("RevitAttachment.Current")
- )
-
- checkbox.IsChecked = True
- if attachments[rvt_ver].AttachmentType == \
- PyRevit.PyRevitAttachmentType.AllUsers:
- checkbox.IsEnabled = False
- checkbox.Content += self.get_locale_string("RevitAttachment.AllUsers")
- else:
- checkbox.IsEnabled = True
- else:
- if rvt_ver in installed_revits:
- checkbox.Content = \
- self._make_product_name(
- installed_revits[rvt_ver],
- self.get_locale_string("RevitAttachment.NotAttached")
- )
- checkbox.IsEnabled = True
- checkbox.IsChecked = False
- else:
- checkbox.Content = \
- self.get_locale_string("RevitAttachment.NotInstalled").format(rvt_ver)
- checkbox.IsEnabled = False
- checkbox.IsChecked = False
+ for checkbox in self.supported_revit_versions_CB:
+ #checkbox.IsEnabled and checkbox.IsChecked are False by default
+ if checkbox.Version not in installed_revits:
+ checkbox.Content += self.get_locale_string("RevitAttachment.NotInstalled")
+ continue
+ product = installed_revits[checkbox.Version]
+ checkbox.Content += ' | {} | {}({}) '.format(product.Name, product.BuildNumber, product.BuildTarget)
+ checkbox.IsEnabled = True
+ if checkbox.Version not in attachments:
+ checkbox.Content += self.get_locale_string("RevitAttachment.NotAttached")
+ continue
+ checkbox.IsChecked = True
+ if checkbox.Version == HOST_APP.version:
+ checkbox.Content += self.get_locale_string("RevitAttachment.Current")
+ if attachments[checkbox.Version].AttachmentType == PyRevit.PyRevitAttachmentType.AllUsers:
+ checkbox.Content += self.get_locale_string("RevitAttachment.AllUsers")
+ checkbox.IsEnabled = False
def is_same_version_as_running(self, version):
return str(version) == EXEC_PARAMS.engine_ver
@@ -454,17 +426,12 @@ def update_addinfiles(self):
)
# now setup the attachments for other versions
- for rvt_ver, checkbox in self._addinfiles_cboxes.items():
+ for checkbox in self.supported_revit_versions_CB:
if checkbox.IsEnabled:
if checkbox.IsChecked:
- PyRevit.PyRevitAttachments.Attach(
- int(rvt_ver),
- attachment.Clone,
- new_engine,
- False
- )
+ PyRevit.PyRevitAttachments.Attach(int(checkbox.Version),attachment.Clone,new_engine,False)
else:
- PyRevit.PyRevitAttachments.Detach(int(rvt_ver))
+ PyRevit.PyRevitAttachments.Detach(int(checkbox.Version))
else:
logger.error('Error determining current attached clone.')