diff --git a/src/blenderbim/blenderbim/bim/module/cost/operator.py b/src/blenderbim/blenderbim/bim/module/cost/operator.py index f42a719ea7..fb98628a93 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/operator.py +++ b/src/blenderbim/blenderbim/bim/module/cost/operator.py @@ -420,7 +420,7 @@ class AddCostItemQuantity(bpy.types.Operator): class RemoveCostItemQuantity(bpy.types.Operator): bl_idname = "bim.remove_cost_item_quantity" - bl_label = "Add Cost Item Quantity" + bl_label = "Remove Cost Item Quantity" bl_options = {"REGISTER", "UNDO"} cost_item: bpy.props.IntProperty() physical_quantity: bpy.props.IntProperty() diff --git a/src/blenderbim/blenderbim/bim/module/cost/prop.py b/src/blenderbim/blenderbim/bim/module/cost/prop.py index 16c48c736c..c02660b537 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/prop.py +++ b/src/blenderbim/blenderbim/bim/module/cost/prop.py @@ -84,7 +84,7 @@ class BIMCostProperties(PropertyGroup): cost_schedule_attributes: CollectionProperty(name="Cost Schedule Attributes", type=Attribute) is_editing: StringProperty(name="Is Editing") active_cost_schedule_id: IntProperty(name="Active Cost Schedule Id") - cost_items: CollectionProperty(name="Work Calendar", type=CostItem) + cost_items: CollectionProperty(name="Cost Items", type=CostItem) active_cost_item_id: IntProperty(name="Active Cost Id") cost_item_editing_type: StringProperty(name="Cost Item Editing Type") active_cost_item_index: IntProperty(name="Active Cost Item Index") diff --git a/src/blenderbim/blenderbim/bim/module/cost/ui.py b/src/blenderbim/blenderbim/bim/module/cost/ui.py index 8f47ecd85e..64cdd14fd9 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/ui.py +++ b/src/blenderbim/blenderbim/bim/module/cost/ui.py @@ -165,7 +165,6 @@ class BIM_PT_cost_schedules(Panel): box = self.layout.box() self.draw_editable_cost_value_ui(box, Data.cost_values[self.props.active_cost_item_value_id]) - def draw_readonly_cost_value_ui(self, layout, cost_value_id): cost_value = Data.cost_values[cost_value_id] cost_value_label = "{0:.2f}".format(cost_value["AppliedValue"]) @@ -236,7 +235,6 @@ class BIM_PT_cost_schedules(Panel): row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="") - class BIM_UL_cost_items(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): if item: @@ -263,7 +261,7 @@ class BIM_UL_cost_items(UIList): op = row.operator("bim.enable_editing_cost_item_quantities", text="", icon="PROPERTIES") op.cost_item = item.ifc_definition_id - row.label(text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + " (M3)") + row.label(text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" ({cost_item['UnitSymbol']})") op = row.operator("bim.enable_editing_cost_item_values", text="", icon="DISC") op.cost_item = item.ifc_definition_id diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/data.py b/src/ifcopenshell-python/ifcopenshell/api/cost/data.py index 9d01cdcbdc..cf59abfff0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/data.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/data.py @@ -1,4 +1,5 @@ import ifcopenshell.util.date +import ifcopenshell.util.unit class Data: @@ -63,6 +64,13 @@ class Data: del quantity_data["Unit"] cls.physical_quantities[quantity.id()] = quantity_data data["CostQuantities"].append(quantity.id()) + data["Unit"] = None + data["UnitSymbol"] = "?" + if cost_item.CostQuantities: + quantity = cost_item.CostQuantities[0] + unit = ifcopenshell.util.unit.get_property_unit(quantity, cls.file) + data["Unit"] = unit.id() + data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit) @classmethod def load_cost_item_values(cls, cost_item, data): diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py index a5bffc2b53..fbc4c46b2b 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/unit.py +++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py @@ -52,6 +52,7 @@ unit_names = [ "WEBER", ] + si_dimensions = { "METRE": (1, 0, 0, 0, 0, 0, 0), "SQUARE_METRE": (2, 0, 0, 0, 0, 0, 0), @@ -121,6 +122,33 @@ si_conversions = { "btu": 1055.056, } +prefix_symbols = { + "EXA": "E", + "PETA": "P", + "TERA": "T", + "GIGA": "G", + "MEGA": "M", + "KILO": "k", + "HECTO": "h", + "DECA": "da", + "DECI": "d", + "CENTI": "c", + "MILLI": "m", + "MICRO": "μ", + "NANO": "n", + "PICO": "p", + "FEMTO": "f", + "ATTO": "a", +} + +unit_symbols = { + "CUBIC_METRE": "m3", + "GRAM": "g", + "SECOND": "s", + "SQUARE_METRE": "m2", + "METRE": "m", +} + def get_prefix(text): if text: @@ -169,6 +197,15 @@ def get_property_unit(prop, ifc_file): return units[0] +def get_unit_symbol(unit): + if unit.is_a("IfcSIUnit"): + symbol = "" + symbol += prefix_symbols.get(unit.Prefix, "") + symbol += unit_symbols.get(unit.Name.replace("METER", "METRE"), "?") + return symbol + return "?" + + def convert(value, from_prefix, from_unit, to_prefix, to_unit): """Converts between length, area, and volume units