Skip to content

Commit a9a7fad

Browse files
authored
Merge pull request #2935 from Wurschdhaud/fix-2934
unify API change handling
2 parents 2addba7 + 5464eb9 commit a9a7fad

File tree

1 file changed

+7
-7
lines changed
  • extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/Tools.stack/Sum.pushbutton

1 file changed

+7
-7
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/Tools.stack/Sum.pushbutton/script.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def is_calculable_param(param):
20-
if HOST_APP.is_newer_than(2022) and not param.Definition.GetDataType().TypeId:
20+
if HOST_APP.is_newer_than(2021) and not param.Definition.GetDataType().TypeId:
2121
return False
2222

2323
if param.StorageType == DB.StorageType.Double:
@@ -32,14 +32,14 @@ def is_calculable_param(param):
3232

3333

3434
def get_definition_type(definition):
35-
if HOST_APP.is_newer_than(2022):
35+
if HOST_APP.is_newer_than(2021):
3636
return definition.GetDataType()
3737
else:
3838
return definition.ParameterType
3939

4040

4141
def get_definition_spec(definition):
42-
if HOST_APP.is_newer_than(2022):
42+
if HOST_APP.is_newer_than(2021):
4343
return DB.LabelUtils.GetLabelForSpec(definition.GetDataType())
4444
else:
4545
return definition.ParameterType
@@ -76,12 +76,12 @@ def _add_total(total, param):
7676

7777
def format_value(total, unit_type):
7878
format_options = revit.doc.GetUnits().GetFormatOptions(unit_type)
79-
try:
80-
units = format_options.DisplayUnits
81-
label = DB.LabelUtils.GetLabelFor(units)
82-
except AttributeError:
79+
if HOST_APP.is_newer_than(2021):
8380
units = format_options.GetUnitTypeId()
8481
label = DB.LabelUtils.GetLabelForUnit(units)
82+
else:
83+
units = format_options.DisplayUnits
84+
label = DB.LabelUtils.GetLabelFor(units)
8585
return "{} {}".format(DB.UnitUtils.ConvertFromInternalUnits(total, units), label)
8686

8787

0 commit comments

Comments
 (0)