From e431cb205c85b5df8b1cbcb8ce4f81217632ad52 Mon Sep 17 00:00:00 2001 From: Massimo Fabbro Date: Sat, 30 Mar 2024 15:19:49 +0100 Subject: [PATCH] improve the ceiling height object quantity calculation --- .../bim/module/pset/qto_calculator.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/pset/qto_calculator.py b/src/blenderbim/blenderbim/bim/module/pset/qto_calculator.py index 753f2202ad..d8cbd9b39d 100644 --- a/src/blenderbim/blenderbim/bim/module/pset/qto_calculator.py +++ b/src/blenderbim/blenderbim/bim/module/pset/qto_calculator.py @@ -246,12 +246,19 @@ class QtoCalculator: return self.get_net_side_area(obj) def get_finish_ceiling_height(self, obj: bpy.types.Object) -> float: - space_height = self.get_height(obj) floor_height = self.get_finish_floor_height(obj) ceiling_height = self.get_ceiling_height(obj) - finish_ceiling_height = space_height - floor_height - ceiling_height + finish_ceiling_height = ceiling_height - floor_height return finish_ceiling_height + def get_max_global_z(self, obj: bpy.types.Object) -> float: + z_values = [(obj.matrix_world @ Vector(co))[2] for co in obj.bound_box] + return max(z_values) + + def get_min_global_z(self, obj: bpy.types.Object) -> float: + z_values = [(obj.matrix_world @ Vector(co))[2] for co in obj.bound_box] + return min(z_values) + def get_finish_floor_height(self, obj: bpy.types.Object) -> float: element = tool.Ifc.get_entity(obj) decompositions = ifcopenshell.util.element.get_decomposition(element) @@ -269,20 +276,23 @@ class QtoCalculator: return finish_floor_height def get_ceiling_height(self, obj: bpy.types.Object) -> float: + space_min_z_value = self.get_min_global_z(obj) + space_max_z_value = self.get_max_global_z(obj) + element = tool.Ifc.get_entity(obj) decompositions = ifcopenshell.util.element.get_decomposition(element) - finish_ceiling_height = 0 + ceiling_min_z_value = space_max_z_value for decomposition in decompositions: if ( decomposition.get_info()["PredefinedType"] == "CEILING" and decomposition.get_info()["type"] == "IfcCovering" ): ceiling_obj = tool.Ifc.get_object(decomposition) - new_finish_ceiling_height = self.get_height(ceiling_obj) - if new_finish_ceiling_height > finish_ceiling_height: - finish_ceiling_height = new_finish_ceiling_height + ceiling_z_value = self.get_min_global_z(ceiling_obj) + if ceiling_z_value < space_max_z_value: + ceiling_min_z_value = ceiling_z_value - return finish_ceiling_height + return ceiling_min_z_value - space_min_z_value def get_net_perimeter(self, o: bpy.types.Object) -> float: parsed_edges = []