mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Fix bug where openings were not unlinked or renamed if they were removed from a non-dynamic object
This commit is contained in:
@@ -91,13 +91,14 @@ class RemoveOpening(bpy.types.Operator):
|
||||
if modifier.type != "BOOLEAN":
|
||||
continue
|
||||
if modifier.object and modifier.object.BIMObjectProperties.ifc_definition_id == self.opening_id:
|
||||
IfcStore.unlink_element(obj=modifier.object)
|
||||
if "/" in modifier.object.name and modifier.object.name[0:3] == "Ifc":
|
||||
modifier.object.name = "/".join(modifier.object.name.split("/")[1:])
|
||||
is_modifier_removed = True
|
||||
obj.modifiers.remove(modifier)
|
||||
break
|
||||
|
||||
opening = IfcStore.get_element(self.opening_id)
|
||||
opening.name = "/".join(opening.name.split("/")[1:])
|
||||
IfcStore.unlink_element(obj=opening)
|
||||
|
||||
ifcopenshell.api.run("void.remove_opening", self.file, **{"opening": self.file.by_id(self.opening_id)})
|
||||
|
||||
if not is_modifier_removed:
|
||||
|
||||
@@ -115,6 +115,11 @@ def the_object_name_is_an_ifc_class(name, ifc_class):
|
||||
assert element.is_a(ifc_class), f'Object "{name}" is a {element.is_a()}'
|
||||
|
||||
|
||||
def the_object_name_is_not_an_ifc_element(name):
|
||||
id = the_object_name_exists(name).BIMObjectProperties.ifc_definition_id
|
||||
assert id == 0, f"The ID is {id}"
|
||||
|
||||
|
||||
def the_object_name_is_in_the_collection_collection(name, collection):
|
||||
assert collection in [c.name for c in the_object_name_exists(name).users_collection]
|
||||
|
||||
@@ -152,6 +157,11 @@ def i_duplicate_the_selected_objects():
|
||||
blenderbim.bim.handler.active_object_callback()
|
||||
|
||||
|
||||
def i_delete_the_selected_objects():
|
||||
bpy.ops.object.delete()
|
||||
blenderbim.bim.handler.active_object_callback()
|
||||
|
||||
|
||||
def the_object_name1_and_name2_are_different_elements(name1, name2):
|
||||
ifc = an_ifc_file_exists()
|
||||
element1 = ifc.by_id(the_object_name_exists(name1).BIMObjectProperties.ifc_definition_id)
|
||||
@@ -167,7 +177,7 @@ def the_file_name_should_contain_value(name, value):
|
||||
def the_object_name1_has_a_boolean_difference_by_name2(name1, name2):
|
||||
obj = the_object_name_exists(name1)
|
||||
for modifier in obj.modifiers:
|
||||
if modifier.type == "BOOLEAN" and modifier.object.name == name2:
|
||||
if modifier.type == "BOOLEAN" and modifier.object and modifier.object.name == name2:
|
||||
return True
|
||||
assert False, "No boolean found"
|
||||
|
||||
@@ -175,7 +185,7 @@ def the_object_name1_has_a_boolean_difference_by_name2(name1, name2):
|
||||
def the_object_name1_has_no_boolean_difference_by_name2(name1, name2):
|
||||
obj = the_object_name_exists(name1)
|
||||
for modifier in obj.modifiers:
|
||||
if modifier.type == "BOOLEAN" and modifier.object.name == name2:
|
||||
if modifier.type == "BOOLEAN" and modifier.object and modifier.object.name == name2:
|
||||
assert False, "A boolean was found"
|
||||
|
||||
|
||||
@@ -215,6 +225,7 @@ definitions = {
|
||||
'I enable "(.*)"': i_enable_prop,
|
||||
'I press "(.*)"': i_press_operator,
|
||||
'the object "(.*)" is an "(.*)"': the_object_name_is_an_ifc_class,
|
||||
'the object "(.*)" is not an IFC element': the_object_name_is_not_an_ifc_element,
|
||||
'the object "(.*)" is in the collection "(.*)"': the_object_name_is_in_the_collection_collection,
|
||||
'the collection "(.*)" is in the collection "(.*)"': the_collection_name1_is_in_the_collection_name2,
|
||||
"an IFC file exists": an_ifc_file_exists,
|
||||
@@ -222,6 +233,7 @@ definitions = {
|
||||
'the object "(.*)" is placed in the collection "(.*)"': the_object_name_is_placed_in_the_collection_collection,
|
||||
'the object "(.*)" is contained in "(.*)"': the_object_name_is_contained_in_container_name,
|
||||
"I duplicate the selected objects": i_duplicate_the_selected_objects,
|
||||
"I delete the selected objects": i_delete_the_selected_objects,
|
||||
'the object "(.*)" and "(.*)" are different elements': the_object_name1_and_name2_are_different_elements,
|
||||
'the file "(.*)" should contain "(.*)"': the_file_name_should_contain_value,
|
||||
'the object "(.*)" has a boolean difference by "(.*)"': the_object_name1_has_a_boolean_difference_by_name2,
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestAddOpening(test.bim.bootstrap.NewFile):
|
||||
|
||||
class TestRemoveOpening(test.bim.bootstrap.NewFile):
|
||||
@test.bim.bootstrap.scenario
|
||||
def test_removing_an_opening(self):
|
||||
def test_removing_an_opening_manually(self):
|
||||
return """
|
||||
Given an empty IFC project
|
||||
When the object "Cube" is selected
|
||||
@@ -53,10 +53,11 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile):
|
||||
And I press "bim.remove_opening(opening_id=97, obj='IfcWall/Cube')"
|
||||
Then the object "IfcWall/Cube" has no boolean difference by "IfcOpeningElement/Cube"
|
||||
And the object "IfcWall/Cube" is not voided by "Cube"
|
||||
And the object "Cube" is not an IFC element
|
||||
"""
|
||||
|
||||
@test.bim.bootstrap.scenario
|
||||
def test_removing_a_non_dynamic_opening(self):
|
||||
def test_removing_a_non_dynamic_opening_manually(self):
|
||||
return """
|
||||
Given an empty IFC project
|
||||
When the object "Cube" is selected
|
||||
@@ -67,10 +68,10 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile):
|
||||
And additionally the object "Cube" is selected
|
||||
And I press "bim.add_opening(opening='Cube', obj='IfcWall/Cube')"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
And I press "bim.print_ifc_file"
|
||||
And I press "bim.switch_representation(ifc_definition_id=86, should_reload=True)"
|
||||
Then the object "IfcWall/Cube" has no boolean difference by "IfcOpeningElement/Cube"
|
||||
And the object "IfcWall/Cube" has "16" vertices
|
||||
When I press "bim.remove_opening(opening_id=97, obj='IfcWall/Cube')"
|
||||
Then the object "IfcWall/Cube" has "8" vertices
|
||||
And the object "Cube" is not an IFC element
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user