diff --git a/src/bonsai/bonsai/bim/module/model/handler.py b/src/bonsai/bonsai/bim/module/model/handler.py index b73e276602..f513017eef 100644 --- a/src/bonsai/bonsai/bim/module/model/handler.py +++ b/src/bonsai/bonsai/bim/module/model/handler.py @@ -42,9 +42,6 @@ def load_post(*args): product.regenerate_profile_usage, ) - ifcopenshell.api.add_post_listener( - "geometry.add_representation", "Bonsai.DumbWall.CalculateQuantities", wall.calculate_quantities - ) ifcopenshell.api.add_post_listener( "material.edit_layer", "Bonsai.DumbWall.RegenerateFromLayer", wall.DumbWallPlaner().regenerate_from_layer ) @@ -52,9 +49,6 @@ def load_post(*args): "type.assign_type", "Bonsai.DumbWall.RegenerateFromType", wall.DumbWallPlaner().regenerate_from_type ) - ifcopenshell.api.add_post_listener( - "geometry.add_representation", "Bonsai.DumbSlab.CalculateQuantities", slab.calculate_quantities - ) ifcopenshell.api.add_post_listener( "material.edit_layer", "Bonsai.DumbSlab.RegenerateFromLayer", slab.DumbSlabPlaner().regenerate_from_layer ) diff --git a/src/bonsai/bonsai/bim/module/model/slab.py b/src/bonsai/bonsai/bim/module/model/slab.py index 63f596f1d3..75f0a7bc6d 100644 --- a/src/bonsai/bonsai/bim/module/model/slab.py +++ b/src/bonsai/bonsai/bim/module/model/slab.py @@ -36,82 +36,6 @@ from bonsai.bim.module.model.decorator import ProfileDecorator from typing import Optional -def calculate_quantities(usecase_path, ifc_file, settings): - unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) - obj = settings["blender_object"] - product = ifc_file.by_id(obj.BIMObjectProperties.ifc_definition_id) - parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric") - if not parametric or "Engine" not in parametric or parametric["Engine"] != "Bonsai.DumbLayer3": - return - qto = ifcopenshell.api.run( - "pset.add_qto", ifc_file, should_run_listeners=False, product=product, name="Qto_SlabBaseQuantities" - ) - length = obj.dimensions[0] / unit_scale - width = obj.dimensions[1] / unit_scale - depth = obj.dimensions[2] / unit_scale - - perimeter = 0 - helper = Helper(ifc_file) - indices = helper.auto_detect_arbitrary_profile_with_voids_extruded_area_solid(settings["geometry"]) - - bm = bmesh.new() - bm.from_mesh(settings["geometry"]) - bm.verts.ensure_lookup_table() - - def calculate_profile_length(indices): - indices.append(indices[0]) # Close the loop - edge_vert_pairs = list(zip(indices, indices[1:])) - return sum([(bm.verts[p[1]].co - bm.verts[p[0]].co).length for p in edge_vert_pairs]) - - perimeter += calculate_profile_length(indices["profile"]) - for inner_indices in indices["inner_curves"]: - perimeter += calculate_profile_length(inner_indices) - - bm.free() - - if product.HasOpenings: - # TODO: calculate gross / net - gross_area = 0 - net_area = 0 - gross_volume = 0 - net_volume = 0 - else: - bm = bmesh.new() - bm.from_object(obj, bpy.context.evaluated_depsgraph_get()) - bm.faces.ensure_lookup_table() - gross_area = sum([f.calc_area() for f in bm.faces if f.normal.z > 0.9]) - net_area = gross_area - gross_volume = bm.calc_volume() - net_volume = gross_volume - bm.free() - - properties = { - "Depth": round(depth, 2), - "Perimeter": round(perimeter, 2), - "GrossArea": round(gross_area, 2), - "NetArea": round(net_area, 2), - "GrossVolume": round(gross_volume, 2), - "NetVolume": round(net_volume, 2), - } - - if round(obj.dimensions[0] * obj.dimensions[1] * obj.dimensions[2], 2) == round(gross_volume, 2): - properties.update( - { - "Length": round(length, 2), - "Width": round(width, 2), - } - ) - else: - properties.update( - { - "Length": None, - "Width": None, - } - ) - - ifcopenshell.api.run("pset.edit_qto", ifc_file, should_run_listeners=False, qto=qto, properties=properties) - - class DumbSlabGenerator: def __init__(self, relating_type: ifcopenshell.entity_instance): self.relating_type = relating_type diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index f458627d0e..9289d12701 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -914,58 +914,6 @@ class DumbWallGenerator: return [c for c in classes if "StandardCase" not in c][0] -def calculate_quantities(usecase_path, ifc_file, settings): - unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) - obj = settings["blender_object"] - product = ifc_file.by_id(obj.BIMObjectProperties.ifc_definition_id) - parametric = ifcopenshell.util.element.get_psets(product).get("EPset_Parametric") - if not parametric or "Engine" not in parametric or parametric["Engine"] != "Bonsai.DumbLayer2": - return - qto = ifcopenshell.api.run( - "pset.add_qto", ifc_file, should_run_listeners=False, product=product, name="Qto_WallBaseQuantities" - ) - length = obj.dimensions[0] / unit_scale - width = obj.dimensions[1] / unit_scale - height = obj.dimensions[2] / unit_scale - - bm_gross = bmesh.new() - bm_gross.from_mesh(obj.data) - bm_gross.faces.ensure_lookup_table() - - bm_net = bmesh.new() - depsgraph = bpy.context.evaluated_depsgraph_get() - evaluated_mesh = obj.evaluated_get(depsgraph).data - bm_net.from_mesh(evaluated_mesh) - bm_net.faces.ensure_lookup_table() - - gross_footprint_area = sum([f.calc_area() for f in bm_gross.faces if f.normal.z < -0.9]) - net_footprint_area = sum([f.calc_area() for f in bm_net.faces if f.normal.z < -0.9]) - gross_side_area = sum([f.calc_area() for f in bm_gross.faces if f.normal.y > 0.9]) - net_side_area = sum([f.calc_area() for f in bm_net.faces if f.normal.y > 0.9]) - gross_volume = bm_gross.calc_volume() - net_volume = bm_net.calc_volume() - bm_gross.free() - bm_net.free() - - ifcopenshell.api.run( - "pset.edit_qto", - ifc_file, - should_run_listeners=False, - qto=qto, - properties={ - "Length": round(length, 2), - "Width": round(width, 2), - "Height": round(height, 2), - "GrossFootprintArea": round(gross_footprint_area, 2), - "NetFootprintArea": round(net_footprint_area, 2), - "GrossSideArea": round(gross_side_area, 2), - "NetSideArea": round(net_side_area, 2), - "GrossVolume": round(gross_volume, 2), - "NetVolume": round(net_volume, 2), - }, - ) - - class DumbWallPlaner: def regenerate_from_layer(self, usecase_path, ifc_file, settings): if settings["attributes"].get("LayerThickness") is None: