Skip to content

Commit

Permalink
Merge pull request #2392 from pyrevitlabs/fix/2381
Browse files Browse the repository at this point in the history
API Deprecation - fix 2381
  • Loading branch information
jmcouffin committed Sep 9, 2024
2 parents 0b2260f + 7a8705e commit edeeb3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
BIND = 'Unknown'

name = p.Name
if HOST_APP.is_newer_than('2022'):
ut = str(p.GetDataType().TypeId)
tp = str(p.GetDataType().TypeId.split('.')[-3])
elif HOST_APP.is_exactly('2022'):
if HOST_APP.is_exactly('2022'):
ut = str(p.GetSpecTypeId().TypeId)
tp = str(p.ParameterType)
elif HOST_APP.is_newer_than('2022'):
ut = str(p.GetDataType().TypeId)
tp = str(p.GetDataType().TypeId.split('.')[-3])
pg = str(p.GetGroupTypeId().TypeId)
else:
pg = str(p.ParameterGroup)
ut = str(p.UnitType)
tp = str(p.ParameterType)
pg = str(p.ParameterGroup)

print('\n')
print('-' * 100)
Expand Down
20 changes: 9 additions & 11 deletions pyrevitlib/pyrevit/revit/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,21 @@ def __init__(self, param_def, param_binding=None, param_ext_def=False):
# Revit <2017 does not have the Id parameter
self.param_id = getattr(self.param_def, 'Id', None)


if HOST_APP.is_newer_than(2022, or_equal=True):
# GetSpecTypeId() Removed in Revit 2022
self.unit_type = self.param_def.GetDataType()
elif HOST_APP.is_exactly(2021):
if HOST_APP.is_exactly(2021):
# Revit >2021 does not have the UnitType property
self.unit_type = self.param_def.GetSpecTypeId()
else:
self.unit_type = self.param_def.UnitType

# Revit >2022 does not have the ParameterType property
if HOST_APP.is_newer_than(2022, or_equal=True):
elif HOST_APP.is_newer_than(2022, or_equal=True):
# GetSpecTypeId() Removed in Revit 2022
self.unit_type = self.param_def.GetDataType()
# Revit >2022 does not have the ParameterType property
self.param_type = self.param_def.GetDataType()
# ParameterGroup deprecated
self.param_group = self.param_def.GetGroupTypeId().TypeId
else:
self.unit_type = self.param_def.UnitType
self.param_type = self.param_def.ParameterType
self.param_group = self.param_def.ParameterGroup

self.param_group = self.param_def.ParameterGroup

def __eq__(self, other):
if isinstance(self.param_def, DB.ExternalDefinition):
Expand Down

0 comments on commit edeeb3e

Please sign in to comment.