mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Purge old dynamic void system as Blender booleans are not sufficient.
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
@@ -25,7 +25,6 @@ classes = (
|
||||
product.AlignProduct,
|
||||
product.ChangeTypePage,
|
||||
product.DisplayConstrTypes,
|
||||
product.DynamicallyVoidProduct,
|
||||
product.LoadTypeThumbnails,
|
||||
product.ReinvokeOperator,
|
||||
workspace.Hotkey,
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user