From 1db5d3b06cbc74e78675b732f332103505c9ac48 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 7 Oct 2022 20:46:54 +1100 Subject: [PATCH] Begin purging old dynamic void feature --- .../bim/module/geometry/operator.py | 1 - .../blenderbim/bim/module/model/__init__.py | 1 + src/blenderbim/blenderbim/core/geometry.py | 5 +--- src/blenderbim/blenderbim/core/tool.py | 3 +-- src/blenderbim/blenderbim/tool/geometry.py | 17 ++----------- src/blenderbim/test/core/test_geometry.py | 14 ++--------- src/blenderbim/test/tool/test_geometry.py | 25 ++----------------- 7 files changed, 9 insertions(+), 57 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index dbd8fc3145..2929f16816 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -381,7 +381,6 @@ class OverrideDeleteTrait: self.remove_port(port) def delete_opening_element(self, element): - obj = IfcStore.get_element(element.VoidsElements[0].RelatingBuildingElement.id()) bpy.ops.bim.remove_opening(opening_id=element.id()) def remove_filling(self, element): diff --git a/src/blenderbim/blenderbim/bim/module/model/__init__.py b/src/blenderbim/blenderbim/bim/module/model/__init__.py index 395e3f72aa..ce253d69a9 100644 --- a/src/blenderbim/blenderbim/bim/module/model/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/model/__init__.py @@ -42,6 +42,7 @@ classes = ( opening.EditOpenings, opening.HideBooleans, opening.HideOpenings, + opening.RecalculateFill, opening.RemoveBooleans, opening.ShowBooleans, opening.ShowOpenings, diff --git a/src/blenderbim/blenderbim/core/geometry.py b/src/blenderbim/blenderbim/core/geometry.py index 2dc982af36..36aa2dc3b3 100644 --- a/src/blenderbim/blenderbim/core/geometry.py +++ b/src/blenderbim/blenderbim/core/geometry.py @@ -97,7 +97,7 @@ def switch_representation( existing_data = geometry.get_representation_data(representation) if should_reload or not existing_data: - data = geometry.import_representation(obj, representation, enable_dynamic_voids=enable_dynamic_voids) + data = geometry.import_representation(obj, representation) geometry.rename_object(data, geometry.get_representation_name(representation)) geometry.link(representation, data) else: @@ -110,9 +110,6 @@ def switch_representation( geometry.clear_modifiers(obj) - if enable_dynamic_voids and geometry.is_body_representation(representation): - geometry.create_dynamic_voids(obj) - def get_representation_ifc_parameters(geometry, obj=None, should_sync_changes_first=False): geometry.import_representation_parameters(geometry.get_object_data(obj)) diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index b12e935916..a8b9318722 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -210,7 +210,6 @@ class Geometry: def clear_cache(cls, element): pass def clear_modifiers(cls, obj): pass def clear_scale(cls, obj): pass - def create_dynamic_voids(cls, obj): pass def delete_data(cls, data): pass def does_representation_id_exist(cls, representation_id): pass def duplicate_object_data(cls, obj): pass @@ -227,7 +226,7 @@ class Geometry: def get_styles(cls, obj): pass def get_total_representation_items(cls, obj): pass def has_data_users(cls, data): pass - def import_representation(cls, obj, representation, enable_dynamic_voids=False): pass + def import_representation(cls, obj, representation): pass def import_representation_parameters(cls, data): pass def is_body_representation(cls, representation): pass def is_box_representation(cls, representation): pass diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 360e237a31..22ea707921 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -58,19 +58,6 @@ class Geometry(blenderbim.core.tool.Geometry): else: obj.scale = Vector((1.0, 1.0, 1.0)) - @classmethod - def create_dynamic_voids(cls, obj): - element = tool.Ifc.get_entity(obj) - for rel in element.HasOpenings: - opening_obj = tool.Ifc.get_object(rel.RelatedOpeningElement) - if not opening_obj: - continue - modifier = obj.modifiers.new("IfcOpeningElement", "BOOLEAN") - modifier.operation = "DIFFERENCE" - modifier.object = opening_obj - modifier.solver = "EXACT" - modifier.use_self = True - @classmethod def delete_data(cls, data): bpy.data.meshes.remove(data) @@ -180,7 +167,7 @@ class Geometry(blenderbim.core.tool.Geometry): return data.users != 0 @classmethod - def import_representation(cls, obj, representation, enable_dynamic_voids=False): + def import_representation(cls, obj, representation): logger = logging.getLogger("ImportIFC") ifc_import_settings = blenderbim.bim.import_ifc.IfcImportSettings.factory(bpy.context, None, logger) element = tool.Ifc.get_entity(obj) @@ -188,7 +175,7 @@ class Geometry(blenderbim.core.tool.Geometry): settings.set(settings.WELD_VERTICES, True) if representation.ContextOfItems.ContextIdentifier == "Body": - if element.is_a("IfcTypeProduct") or enable_dynamic_voids: + if element.is_a("IfcTypeProduct"): shape = ifcopenshell.geom.create_shape(settings, representation) else: shape = ifcopenshell.geom.create_shape(settings, element) diff --git a/src/blenderbim/test/core/test_geometry.py b/src/blenderbim/test/core/test_geometry.py index 3ec625fb24..4ce6d6352e 100644 --- a/src/blenderbim/test/core/test_geometry.py +++ b/src/blenderbim/test/core/test_geometry.py @@ -194,16 +194,12 @@ class TestSwitchRepresentation: geometry.is_edited("obj").should_be_called().will_return(False) geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") geometry.get_representation_data("representation").should_be_called().will_return(None) - geometry.import_representation( - "obj", "representation", enable_dynamic_voids=True - ).should_be_called().will_return("new_data") + geometry.import_representation("obj", "representation").should_be_called().will_return("new_data") geometry.get_representation_name("representation").should_be_called().will_return("name") geometry.rename_object("new_data", "name").should_be_called() geometry.link("representation", "new_data").should_be_called() geometry.change_object_data("obj", "new_data", is_global=True).should_be_called() geometry.clear_modifiers("obj").should_be_called() - geometry.is_body_representation("representation").should_be_called().will_return(True) - geometry.create_dynamic_voids("obj").should_be_called() subject.switch_representation( geometry, obj="obj", @@ -218,17 +214,13 @@ class TestSwitchRepresentation: geometry.is_edited("obj").should_be_called().will_return(False) geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") geometry.get_representation_data("representation").should_be_called().will_return("existing_data") - geometry.import_representation( - "obj", "representation", enable_dynamic_voids=True - ).should_be_called().will_return("new_data") + geometry.import_representation("obj", "representation").should_be_called().will_return("new_data") geometry.get_representation_name("representation").should_be_called().will_return("name") geometry.rename_object("new_data", "name").should_be_called() geometry.link("representation", "new_data").should_be_called() geometry.change_object_data("obj", "new_data", is_global=True).should_be_called() geometry.delete_data("existing_data").should_be_called() geometry.clear_modifiers("obj").should_be_called() - geometry.is_body_representation("representation").should_be_called().will_return(True) - geometry.create_dynamic_voids("obj").should_be_called() subject.switch_representation( geometry, obj="obj", @@ -245,8 +237,6 @@ class TestSwitchRepresentation: geometry.get_representation_data("representation").should_be_called().will_return("data") geometry.change_object_data("obj", "data", is_global=True).should_be_called() geometry.clear_modifiers("obj").should_be_called() - geometry.is_body_representation("representation").should_be_called().will_return(True) - geometry.create_dynamic_voids("obj").should_be_called() subject.switch_representation( geometry, obj="obj", diff --git a/src/blenderbim/test/tool/test_geometry.py b/src/blenderbim/test/tool/test_geometry.py index 9de2f899a3..bad88ada73 100644 --- a/src/blenderbim/test/tool/test_geometry.py +++ b/src/blenderbim/test/tool/test_geometry.py @@ -74,27 +74,6 @@ class TestClearScale(NewFile): assert list(obj.scale) == [1, 1, 1] -class TestCreateDynamicVoids(NewFile): - def test_run(self): - ifc = ifcopenshell.file() - tool.Ifc.set(ifc) - wall = ifc.createIfcWall() - opening = ifc.createIfcOpeningElement() - ifcopenshell.api.run("void.add_opening", ifc, opening=opening, element=wall) - wall_obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh")) - opening_obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh")) - tool.Ifc.link(wall, wall_obj) - tool.Ifc.link(opening, opening_obj) - subject.create_dynamic_voids(wall_obj) - modifier = wall_obj.modifiers[0] - assert modifier.type == "BOOLEAN" - assert modifier.name == "IfcOpeningElement" - assert modifier.operation == "DIFFERENCE" - assert modifier.object == opening_obj - assert modifier.solver == "EXACT" - assert modifier.use_self is True - - class TestDeleteData(NewFile): def test_run(self): data = bpy.data.meshes.new("Mesh") @@ -263,7 +242,7 @@ class TestImportRepresentation(NewFile): element = ifc.by_type("IfcWall")[0] tool.Ifc.link(element, obj) representation = element.Representation.Representations[0] - mesh = subject.import_representation(obj, representation, enable_dynamic_voids=False) + mesh = subject.import_representation(obj, representation) assert len(mesh.polygons) == 12 assert mesh.materials[0] == material @@ -274,7 +253,7 @@ class TestImportRepresentation(NewFile): element = ifc.by_type("IfcWall")[0] tool.Ifc.link(element, obj) representation = element.Representation.Representations[0] - mesh = subject.import_representation(obj, representation, enable_dynamic_voids=False) + mesh = subject.import_representation(obj, representation) assert len(mesh.polygons) == 0 assert len(mesh.edges) == 4