mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Fix bug where drawing decimal places couldn't be 0. Now it's possible to define 0 as value
This commit is contained in:
@@ -208,19 +208,19 @@ def format_distance(
|
|||||||
if precision:
|
if precision:
|
||||||
value = precision * round(float(value) / precision)
|
value = precision * round(float(value) / precision)
|
||||||
|
|
||||||
if decimal_places:
|
if decimal_places is not None:
|
||||||
fmt = "%1." + str(decimal_places) + "f"
|
fmt = "%1." + str(decimal_places) + "f"
|
||||||
|
|
||||||
# Meters
|
# Meters
|
||||||
if unit_length == "METERS":
|
if unit_length == "METERS":
|
||||||
if not decimal_places:
|
if decimal_places is None:
|
||||||
fmt = "%1.3f"
|
fmt = "%1.3f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " m"
|
fmt += " m"
|
||||||
tx_dist = fmt % value
|
tx_dist = fmt % value
|
||||||
# Centimeters
|
# Centimeters
|
||||||
elif unit_length == "CENTIMETERS":
|
elif unit_length == "CENTIMETERS":
|
||||||
if not decimal_places:
|
if decimal_places is None:
|
||||||
fmt = "%1.1f"
|
fmt = "%1.1f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " cm"
|
fmt += " cm"
|
||||||
@@ -228,7 +228,7 @@ def format_distance(
|
|||||||
tx_dist = fmt % d_cm
|
tx_dist = fmt % d_cm
|
||||||
# Millimeters
|
# Millimeters
|
||||||
elif unit_length == "MILLIMETERS":
|
elif unit_length == "MILLIMETERS":
|
||||||
if not decimal_places:
|
if decimal_places is None:
|
||||||
fmt = "%1.0f"
|
fmt = "%1.0f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " mm"
|
fmt += " mm"
|
||||||
@@ -237,20 +237,20 @@ def format_distance(
|
|||||||
|
|
||||||
# Otherwise Use Adaptive Units
|
# Otherwise Use Adaptive Units
|
||||||
else:
|
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"
|
fmt = "%1.3f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " m"
|
fmt += " m"
|
||||||
tx_dist = fmt % value
|
tx_dist = fmt % value
|
||||||
else:
|
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"
|
fmt = "%1.1f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " cm"
|
fmt += " cm"
|
||||||
d_cm = value * (100)
|
d_cm = value * (100)
|
||||||
tx_dist = fmt % d_cm
|
tx_dist = fmt % d_cm
|
||||||
else:
|
else:
|
||||||
if not decimal_places:
|
if decimal_places is None:
|
||||||
fmt = "%1.0f"
|
fmt = "%1.0f"
|
||||||
if hide_units is False:
|
if hide_units is False:
|
||||||
fmt += " mm"
|
fmt += " mm"
|
||||||
|
|||||||
Reference in New Issue
Block a user