Skip to content

Commit

Permalink
Update units.py (#1534)
Browse files Browse the repository at this point in the history
case for revit 2022 'UnitType' deprecation for 'SpecTypeId' in format slope def
  • Loading branch information
jmcouffin committed May 31, 2022
1 parent 5db685e commit 8755013
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pyrevitlib/pyrevit/revit/units.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit conversion utilities for Revit."""

from pyrevit import DOCS
from pyrevit import DOCS, HOST_APP
from pyrevit import DB


Expand Down Expand Up @@ -33,7 +33,14 @@ def format_slope(slope_value, doc=None):
str: formatted value
"""
doc = doc or DOCS.doc
return DB.UnitFormatUtils.Format(units=doc.GetUnits(),
if HOST_APP.is_newer_than(2021):
return DB.UnitFormatUtils.Format(units=doc.GetUnits(),
unitType=DB.SpecTypeId.Slope,
value=slope_value,
maxAccuracy=False,
forEditing=False)
else:
return DB.UnitFormatUtils.Format(units=doc.GetUnits(),
unitType=DB.UnitType.UT_Slope,
value=slope_value,
maxAccuracy=False,
Expand Down

0 comments on commit 8755013

Please sign in to comment.