Begin purging old dynamic void feature

This commit is contained in:
Dion Moult
2022-10-07 20:46:54 +11:00
parent 3b81c158f3
commit 1db5d3b06c
7 changed files with 9 additions and 57 deletions
@@ -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):
@@ -42,6 +42,7 @@ classes = (
opening.EditOpenings,
opening.HideBooleans,
opening.HideOpenings,
opening.RecalculateFill,
opening.RemoveBooleans,
opening.ShowBooleans,
opening.ShowOpenings,
+1 -4
View File
@@ -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))
+1 -2
View File
@@ -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
+2 -15
View File
@@ -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)
+2 -12
View File
@@ -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",
+2 -23
View File
@@ -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