mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 16:43:00 +00:00
Fix bug where deleting the drawing object could lead to orphaned relationships
This commit is contained in:
@@ -47,3 +47,29 @@ Scenario: Create drawing after deleting a duplicated object
|
||||
And I press "object.delete(use_global=False)"
|
||||
When I press "bim.create_drawing"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Remove drawing
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
||||
And I press "bim.add_drawing"
|
||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
||||
And the collection "IfcGroup/PLAN_VIEW" exists
|
||||
When I press "bim.remove_drawing(drawing={drawing})"
|
||||
Then the collection "IfcGroup/PLAN_VIEW" does not exist
|
||||
|
||||
Scenario: Remove drawing - via object deletion
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
||||
And I press "bim.add_drawing"
|
||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
||||
And the object "IfcAnnotation/PLAN_VIEW" is selected
|
||||
When I press "bim.override_object_delete"
|
||||
Then the collection "IfcGroup/PLAN_VIEW" does not exist
|
||||
|
||||
@@ -262,7 +262,7 @@ Scenario: Override delete - without active IFC data
|
||||
Given an empty Blender session
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
When I press "object.delete"
|
||||
When I press "bim.override_object_delete"
|
||||
Then the object "Cube" does not exist
|
||||
|
||||
Scenario: Override delete - with active IFC data
|
||||
@@ -272,7 +272,7 @@ Scenario: Override delete - with active IFC data
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
When I press "object.delete"
|
||||
When I press "bim.override_object_delete"
|
||||
Then the object "IfcWall/Cube" does not exist
|
||||
|
||||
Scenario: Override outliner delete
|
||||
|
||||
@@ -301,6 +301,16 @@ def the_object_name_exists(name) -> bpy.types.Object:
|
||||
return obj
|
||||
|
||||
|
||||
@given(parsers.parse('the collection "{name}" exists'))
|
||||
@when(parsers.parse('the collection "{name}" exists'))
|
||||
@then(parsers.parse('the collection "{name}" exists'))
|
||||
def the_collection_name_exists(name) -> bpy.types.Collection:
|
||||
obj = bpy.data.collections.get(name)
|
||||
if not obj:
|
||||
assert False, f'The collection "{name}" does not exist'
|
||||
return obj
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name1}" and "{name2}" are different elements'))
|
||||
def the_object_name1_and_name2_are_different_elements(name1, name2):
|
||||
ifc = an_ifc_file_exists()
|
||||
@@ -585,7 +595,13 @@ def the_collection_name1_is_in_the_collection_name2(name1, name2):
|
||||
@then(parsers.parse('the object "{name}" does not exist'))
|
||||
def the_object_name_does_not_exist(name):
|
||||
obj = bpy.data.objects.get(name)
|
||||
assert obj is None or len(obj.users_collection) == 0, "Object exists"
|
||||
assert obj is None or len(obj.users_collection) == 0, f"Object {name} exists"
|
||||
|
||||
|
||||
@then(parsers.parse('the collection "{name}" does not exist'))
|
||||
def the_collection_name_does_not_exist(name):
|
||||
obj = bpy.data.collections.get(name)
|
||||
assert obj is None, f"Collection {name} exists"
|
||||
|
||||
|
||||
@then(parsers.parse('objects starting with "{name}" do not exist'))
|
||||
|
||||
Reference in New Issue
Block a user