From 80020970e19944b9e632002822d7db78fcd3af6f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 19 Oct 2022 12:32:02 +1100 Subject: [PATCH] Purge old dynamic void system as Blender booleans are not sufficient. --- .../bim/module/geometry/operator.py | 2 - .../blenderbim/bim/module/model/__init__.py | 1 - .../blenderbim/bim/module/model/opening.py | 5 --- .../blenderbim/bim/module/model/product.py | 40 ------------------- .../blenderbim/bim/module/model/profile.py | 2 - .../blenderbim/bim/module/model/slab.py | 6 --- .../blenderbim/bim/module/model/wall.py | 4 -- .../blenderbim/bim/module/void/operator.py | 2 - src/blenderbim/blenderbim/core/geometry.py | 1 - src/blenderbim/blenderbim/core/tool.py | 3 +- src/blenderbim/blenderbim/tool/type.py | 10 +---- src/blenderbim/test/core/test_geometry.py | 21 ---------- src/blenderbim/test/tool/test_type.py | 11 ----- .../ifcopenshell/util/selector.py | 2 +- 14 files changed, 3 insertions(+), 107 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index 66fdb9e96f..b090e4d713 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -136,7 +136,6 @@ class SwitchRepresentation(bpy.types.Operator, Operator): obj=obj, representation=representation, should_reload=self.should_reload, - enable_dynamic_voids=self.disable_opening_subtractions, is_global=self.should_switch_all_meshes, should_sync_changes_first=True, ) @@ -293,7 +292,6 @@ class UpdateParametricRepresentation(bpy.types.Operator): obj=obj, representation=tool.Ifc.get().by_id(props.ifc_definition_id), should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/bim/module/model/__init__.py b/src/blenderbim/blenderbim/bim/module/model/__init__.py index 19335f75c7..3ac8f1317b 100644 --- a/src/blenderbim/blenderbim/bim/module/model/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/model/__init__.py @@ -25,7 +25,6 @@ classes = ( product.AlignProduct, product.ChangeTypePage, product.DisplayConstrTypes, - product.DynamicallyVoidProduct, product.LoadTypeThumbnails, product.ReinvokeOperator, workspace.Hotkey, diff --git a/src/blenderbim/blenderbim/bim/module/model/opening.py b/src/blenderbim/blenderbim/bim/module/model/opening.py index 5febdc5e9f..f1116aa186 100644 --- a/src/blenderbim/blenderbim/bim/module/model/opening.py +++ b/src/blenderbim/blenderbim/bim/module/model/opening.py @@ -109,7 +109,6 @@ class AddFilledOpening(bpy.types.Operator, tool.Ifc.Operator): obj=voided_obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -252,7 +251,6 @@ class RecalculateFill(bpy.types.Operator, tool.Ifc.Operator): obj=building_obj, representation=body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -421,7 +419,6 @@ class AddBoolean(Operator, tool.Ifc.Operator): obj=obj1, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -549,7 +546,6 @@ class RemoveBooleans(Operator, tool.Ifc.Operator, AddObjectHelper): obj=upstream_obj, representation=body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -632,7 +628,6 @@ class EditOpenings(Operator, tool.Ifc.Operator): obj=obj, representation=body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index 2f044de88c..45de4dbb3c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -311,45 +311,6 @@ class AlignProduct(bpy.types.Operator): return results -class DynamicallyVoidProduct(bpy.types.Operator): - bl_idname = "bim.dynamically_void_product" - bl_label = "Dynamically Void Product" - bl_options = {"REGISTER", "UNDO"} - obj: bpy.props.StringProperty() - - @classmethod - def poll(cls, context): - return IfcStore.get_file() - - def execute(self, context): - obj = bpy.data.objects.get(self.obj) - if obj is None: - return {"FINISHED"} - product = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id) - if not product.HasOpenings: - return {"FINISHED"} - if [m for m in obj.modifiers if m.type == "BOOLEAN"]: - return {"FINISHED"} - representation = ifcopenshell.util.representation.get_representation(product, "Model", "Body", "MODEL_VIEW") - if not representation: - return {"FINISHED"} - was_edit_mode = obj.mode == "EDIT" - if was_edit_mode: - bpy.ops.object.mode_set(mode="OBJECT") - blenderbim.core.geometry.switch_representation( - tool.Geometry, - obj=obj, - representation=representation, - should_reload=True, - enable_dynamic_voids=True, - is_global=True, - should_sync_changes_first=False, - ) - if was_edit_mode: - bpy.ops.object.mode_set(mode="EDIT") - return {"FINISHED"} - - class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.load_type_thumbnails" bl_label = "Load Type Thumbnails" @@ -517,7 +478,6 @@ def regenerate_profile_usage(usecase_path, ifc_file, settings): obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=True, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/bim/module/model/profile.py b/src/blenderbim/blenderbim/bim/module/model/profile.py index 9b702c48af..40c6f53db2 100644 --- a/src/blenderbim/blenderbim/bim/module/model/profile.py +++ b/src/blenderbim/blenderbim/bim/module/model/profile.py @@ -184,7 +184,6 @@ class DumbProfileGenerator: obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -506,7 +505,6 @@ class DumbProfileJoiner: obj=obj, representation=new_body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/bim/module/model/slab.py b/src/blenderbim/blenderbim/bim/module/model/slab.py index 99d8d3885d..e9a423a51c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/slab.py +++ b/src/blenderbim/blenderbim/bim/module/model/slab.py @@ -199,7 +199,6 @@ class DumbSlabGenerator: obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -291,7 +290,6 @@ class DumbSlabPlaner: obj=obj, representation=new_rep, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -310,7 +308,6 @@ class DumbSlabPlaner: obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -517,7 +514,6 @@ class EditSketchExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator): obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -570,7 +566,6 @@ class DisableEditingExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator): obj=obj, representation=body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -786,7 +781,6 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator): obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/bim/module/model/wall.py b/src/blenderbim/blenderbim/bim/module/model/wall.py index c76da24577..72d5f982f6 100644 --- a/src/blenderbim/blenderbim/bim/module/model/wall.py +++ b/src/blenderbim/blenderbim/bim/module/model/wall.py @@ -56,7 +56,6 @@ def mode_callback(obj, data): if not parametric or parametric["Engine"] != "BlenderBIM.DumbLayer2": return if obj.mode == "EDIT": - bpy.ops.bim.dynamically_void_product(obj=obj.name) IfcStore.edited_objs.add(obj) bm = bmesh.from_edit_mesh(obj.data) bmesh.ops.dissolve_limit(bm, angle_limit=pi / 180 * 1, verts=bm.verts, edges=bm.edges) @@ -613,7 +612,6 @@ class DumbWallGenerator: obj=obj, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -840,7 +838,6 @@ class DumbWallJoiner: obj=wall1, representation=body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -1126,7 +1123,6 @@ class DumbWallJoiner: obj=obj, representation=new_body, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/bim/module/void/operator.py b/src/blenderbim/blenderbim/bim/module/void/operator.py index 24e2222dbc..721576867e 100644 --- a/src/blenderbim/blenderbim/bim/module/void/operator.py +++ b/src/blenderbim/blenderbim/bim/module/void/operator.py @@ -84,7 +84,6 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator): obj=obj1, representation=representation, should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) @@ -120,7 +119,6 @@ class RemoveOpening(bpy.types.Operator, tool.Ifc.Operator): obj=obj, representation=tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id), should_reload=True, - enable_dynamic_voids=False, is_global=True, should_sync_changes_first=False, ) diff --git a/src/blenderbim/blenderbim/core/geometry.py b/src/blenderbim/blenderbim/core/geometry.py index 36aa2dc3b3..395ecada21 100644 --- a/src/blenderbim/blenderbim/core/geometry.py +++ b/src/blenderbim/blenderbim/core/geometry.py @@ -83,7 +83,6 @@ def switch_representation( obj=None, representation=None, should_reload=True, - enable_dynamic_voids=True, is_global=True, should_sync_changes_first=False, ): diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index edd7e4c01d..2b4a7a27c6 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -638,10 +638,9 @@ class Type: def get_object_data(cls, obj): pass def get_profile_set_usage(cls, element): pass def get_representation_context(cls, representation): pass - def has_dynamic_voids(cls, obj): pass def has_material_usage(cls, element): pass def run_geometry_add_representation(cls, obj=None, context=None, ifc_representation_class=None, profile_set_usage=None): pass - def run_geometry_switch_representation(cls, obj=None, representation=None, should_reload=None, enable_dynamic_voids=None, is_global=None): pass + def run_geometry_switch_representation(cls, obj=None, representation=None, should_reload=None, is_global=None): pass @interface diff --git a/src/blenderbim/blenderbim/tool/type.py b/src/blenderbim/blenderbim/tool/type.py index 16730d13c0..a36de6b66d 100644 --- a/src/blenderbim/blenderbim/tool/type.py +++ b/src/blenderbim/blenderbim/tool/type.py @@ -74,13 +74,6 @@ class Type(blenderbim.core.tool.Type): def get_representation_context(cls, representation): return representation.ContextOfItems - @classmethod - def has_dynamic_voids(cls, obj): - for modifier in obj.modifiers: - if modifier.name == "IfcOpeningElement" and modifier.type == "BOOLEAN": - return True - return False - @classmethod def has_material_usage(cls, element): material = ifcopenshell.util.element.get_material(element) @@ -105,14 +98,13 @@ class Type(blenderbim.core.tool.Type): @classmethod def run_geometry_switch_representation( - cls, obj=None, representation=None, should_reload=None, enable_dynamic_voids=None, is_global=None + cls, obj=None, representation=None, should_reload=None, is_global=None ): return blenderbim.core.geometry.switch_representation( tool.Geometry, obj=obj, representation=representation, should_reload=should_reload, - enable_dynamic_voids=enable_dynamic_voids, is_global=is_global, should_sync_changes_first=False, ) diff --git a/src/blenderbim/test/core/test_geometry.py b/src/blenderbim/test/core/test_geometry.py index 4ce6d6352e..b63c26b4df 100644 --- a/src/blenderbim/test/core/test_geometry.py +++ b/src/blenderbim/test/core/test_geometry.py @@ -205,7 +205,6 @@ class TestSwitchRepresentation: obj="obj", representation="mapped_rep", should_reload=True, - enable_dynamic_voids=True, is_global=True, should_sync_changes_first=True, ) @@ -226,7 +225,6 @@ class TestSwitchRepresentation: obj="obj", representation="mapped_rep", should_reload=True, - enable_dynamic_voids=True, is_global=True, should_sync_changes_first=True, ) @@ -242,27 +240,10 @@ class TestSwitchRepresentation: obj="obj", representation="mapped_rep", should_reload=False, - enable_dynamic_voids=True, is_global=True, should_sync_changes_first=True, ) - def test_switching_to_non_dynamic_baked_voids(self, geometry): - 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("data") - geometry.change_object_data("obj", "data", is_global=False).should_be_called() - geometry.clear_modifiers("obj").should_be_called() - subject.switch_representation( - geometry, - obj="obj", - representation="mapped_rep", - should_reload=False, - enable_dynamic_voids=False, - is_global=False, - should_sync_changes_first=True, - ) - def test_updating_a_representation_if_the_blender_object_has_been_edited_prior_to_switching(self, geometry): geometry.is_edited("obj").should_be_called().will_return(True) geometry.is_box_representation("mapped_rep").should_be_called().will_return(False) @@ -278,7 +259,6 @@ class TestSwitchRepresentation: obj="obj", representation="mapped_rep", should_reload=False, - enable_dynamic_voids=False, is_global=False, should_sync_changes_first=True, ) @@ -294,7 +274,6 @@ class TestSwitchRepresentation: obj="obj", representation="mapped_rep", should_reload=False, - enable_dynamic_voids=False, is_global=False, should_sync_changes_first=True, ) diff --git a/src/blenderbim/test/tool/test_type.py b/src/blenderbim/test/tool/test_type.py index 689866682e..2f8d1ea09e 100644 --- a/src/blenderbim/test/tool/test_type.py +++ b/src/blenderbim/test/tool/test_type.py @@ -139,17 +139,6 @@ class TestGetRepresentationContext(NewFile): assert subject.get_representation_context(representation) == context -class TestHasDynamicVoids(NewFile): - def test_run(self): - obj = bpy.data.objects.new("Object", None) - assert subject.has_dynamic_voids(obj) is False - - def test_checking_modifiers(self): - obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh")) - obj.modifiers.new("IfcOpeningElement", "BOOLEAN") - assert subject.has_dynamic_voids(obj) is True - - class TestHasMaterialUsage(NewFile): def test_getting_a_profile_set_usage(self): ifc = ifcopenshell.file() diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 8ac4f270be..a1adeedf6c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -198,7 +198,7 @@ class Selector: return results @classmethod - def get_element_value(cls, element, key, value): + def get_element_value(cls, element, key, value=None): if "." in key and key.split(".")[0] == "type": try: element = ifcopenshell.util.element.get_type(element)