From aa0d1cc230b30f409fdb591d6b9ed78e61b6aef4 Mon Sep 17 00:00:00 2001 From: "Sigma Dimensions (Yass)" <79010126+myoualid@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:01:52 +0100 Subject: [PATCH] fix displaying undefined or userdefined units in cost schedules --- src/blenderbim/blenderbim/bim/module/cost/data.py | 6 ++++-- src/ifcopenshell-python/ifcopenshell/util/unit.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/cost/data.py b/src/blenderbim/blenderbim/bim/module/cost/data.py index 16d915c6a2..12af066c9d 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/data.py +++ b/src/blenderbim/blenderbim/bim/module/cost/data.py @@ -158,8 +158,10 @@ class CostSchedulesData: unit = ifcopenshell.util.unit.get_property_unit(quantity, tool.Ifc.get()) if unit: data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit) - else: - data["UnitSymbol"] = "U" + if quantity.is_a("IfcPhysicalSimpleQuantity"): + measure_class = quantity.wrapped_data.declaration().as_entity().attribute_by_index(3).type_of_attribute().declared_type().name() + if "Count" in measure_class: + data["UnitSymbol"] = "U" # same_unit_nested_cost_item = set() # data["DerivedTotalCostQuantity"] = None diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py index a96c424835..29561605a4 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/unit.py +++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py @@ -464,6 +464,8 @@ def get_unit_symbol(unit): if unit.is_a("IfcSIUnit"): symbol += prefix_symbols.get(unit.Prefix, "") symbol += unit_symbols.get(unit.Name.replace("METER", "METRE"), "?") + if unit.is_a("IfcContextDependentUnit") and unit.UnitType == "USERDEFINED": + symbol = unit.Name return symbol