From 757277cedf205df885793ef444e0a027c29cf2ec Mon Sep 17 00:00:00 2001 From: Massimo Fabbro Date: Sun, 9 Jul 2023 18:00:46 +0200 Subject: [PATCH] Fix bug where drawing decimal places couldn't be 0. Now it's possible to define 0 as value --- .../blenderbim/bim/module/drawing/helper.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/helper.py b/src/blenderbim/blenderbim/bim/module/drawing/helper.py index 562be3aaae..100880fb26 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/helper.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/helper.py @@ -208,19 +208,19 @@ def format_distance( if precision: value = precision * round(float(value) / precision) - if decimal_places: + if decimal_places is not None: fmt = "%1." + str(decimal_places) + "f" # Meters if unit_length == "METERS": - if not decimal_places: + if decimal_places is None: fmt = "%1.3f" if hide_units is False: fmt += " m" tx_dist = fmt % value # Centimeters elif unit_length == "CENTIMETERS": - if not decimal_places: + if decimal_places is None: fmt = "%1.1f" if hide_units is False: fmt += " cm" @@ -228,7 +228,7 @@ def format_distance( tx_dist = fmt % d_cm # Millimeters elif unit_length == "MILLIMETERS": - if not decimal_places: + if decimal_places is None: fmt = "%1.0f" if hide_units is False: fmt += " mm" @@ -237,20 +237,20 @@ def format_distance( # Otherwise Use Adaptive Units else: - if round(value, 2) >= 1.0 and not decimal_places: + if round(value, 2) >= 1.0 and decimal_places is None: fmt = "%1.3f" if hide_units is False: fmt += " m" tx_dist = fmt % value else: - if round(value, 2) >= 0.01 and not decimal_places: + if round(value, 2) >= 0.01 and decimal_places is None: fmt = "%1.1f" if hide_units is False: fmt += " cm" d_cm = value * (100) tx_dist = fmt % d_cm else: - if not decimal_places: + if decimal_places is None: fmt = "%1.0f" if hide_units is False: fmt += " mm"