From 4336b9c1aed478a1e2eef10bf9b507e11b5192df Mon Sep 17 00:00:00 2001 From: ceegartner <83513981+ceegartner@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:50:53 +0200 Subject: [PATCH] Update unit.py - convert function, case issue Hi, I noticed an issue and suggest a fix: Unit names from are all lowercase, whereas project units extracted from the IFC files with are uppercase. So the convert function didn't seem to work properly. Hope this helps! --- src/ifcopenshell-python/ifcopenshell/util/unit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py index 29561605a4..28bc705f00 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/unit.py +++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py @@ -506,8 +506,8 @@ def convert(value, from_prefix, from_unit, to_prefix, to_unit): :return: The converted value. :rtype: float """ - if from_unit in si_conversions: - value *= si_conversions[from_unit] + if from_unit.lower() in si_conversions: + value *= si_conversions[from_unit.lower()] elif from_prefix: value *= get_prefix_multiplier(from_prefix) if "SQUARE" in from_unit: @@ -515,8 +515,8 @@ def convert(value, from_prefix, from_unit, to_prefix, to_unit): elif "CUBIC" in from_unit: value *= get_prefix_multiplier(from_prefix) value *= get_prefix_multiplier(from_prefix) - if to_unit in si_conversions: - return value * (1 / si_conversions[to_unit]) + if to_unit.lower() in si_conversions: + return value * (1 / si_conversions[to_unit.lower()]) elif to_prefix: value *= 1 / get_prefix_multiplier(to_prefix) if "SQUARE" in from_unit: