mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 17:26:30 +00:00
Fix critical bug where duplicate orphaned collections were created in the background.
This commit is contained in:
@@ -116,7 +116,6 @@ class TestAssignClass:
|
||||
root.run_geometry_add_representation(
|
||||
obj="obj", context="context", ifc_representation_class="ifc_representation_class", profile_set_usage=None
|
||||
).should_be_called()
|
||||
root.set_element_specific_display_settings("obj", "element").should_be_called()
|
||||
collector.sync("obj").should_be_called()
|
||||
collector.assign("obj").should_be_called()
|
||||
subject.assign_class(
|
||||
@@ -139,7 +138,6 @@ class TestAssignClass:
|
||||
).should_be_called().will_return("element")
|
||||
root.set_object_name("obj", "element").should_be_called()
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.set_element_specific_display_settings("obj", "element").should_be_called()
|
||||
collector.sync("obj").should_be_called()
|
||||
collector.assign("obj").should_be_called()
|
||||
subject.assign_class(
|
||||
|
||||
@@ -72,6 +72,25 @@ class TestAssign(NewFile):
|
||||
assert len(space_obj.users_collection) == 1
|
||||
assert space_obj.users_collection[0].name == space_obj.name
|
||||
|
||||
def test_in_decomposition_mode_multiple_assigns_do_not_create_duplicate_spatial_structure_collections(self):
|
||||
bpy.ops.bim.create_project()
|
||||
space_obj = bpy.data.objects.new("IfcSpace/Name", None)
|
||||
space_element = tool.Ifc.get().createIfcSpace()
|
||||
tool.Ifc.link(space_element, space_obj)
|
||||
bpy.context.scene.collection.objects.link(space_obj)
|
||||
ifcopenshell.api.run(
|
||||
"aggregate.assign_object",
|
||||
tool.Ifc.get(),
|
||||
relating_object=tool.Ifc.get().by_type("IfcSite")[0],
|
||||
product=space_element,
|
||||
)
|
||||
subject.assign(space_obj)
|
||||
subject.assign(space_obj)
|
||||
assert bpy.data.collections.get("IfcSpace/Name")
|
||||
assert bpy.data.collections.get("IfcSite/My Site")
|
||||
assert not bpy.data.collections.get("IfcSpace/Name.001")
|
||||
assert not bpy.data.collections.get("IfcSite/My Site.001")
|
||||
|
||||
def test_in_decomposition_mode_spatial_zone_elements_are_not_placed_in_a_collection_of_the_same_name(self):
|
||||
bpy.ops.bim.create_project()
|
||||
space_obj = bpy.data.objects.new("IfcSpaceZone/Name", None)
|
||||
@@ -116,6 +135,17 @@ class TestAssign(NewFile):
|
||||
assert len(element_obj.users_collection) == 1
|
||||
assert element_obj.users_collection[0].name == element_obj.name
|
||||
|
||||
def test_in_decomposition_mode_multiple_assigns_do_not_create_duplicate_collections(self):
|
||||
tool.Ifc.set(ifcopenshell.file())
|
||||
element_obj = bpy.data.objects.new("IfcProject/Name", None)
|
||||
element = tool.Ifc.get().createIfcProject()
|
||||
tool.Ifc.link(element, element_obj)
|
||||
bpy.context.scene.collection.objects.link(element_obj)
|
||||
subject.assign(element_obj)
|
||||
subject.assign(element_obj)
|
||||
assert bpy.data.collections.get("IfcProject/Name")
|
||||
assert not bpy.data.collections.get("IfcProject/Name.001")
|
||||
|
||||
def test_in_decomposition_mode_existing_collections_are_reassigned_to_the_correct_place_in_the_hierarchy(self):
|
||||
bpy.ops.bim.create_project()
|
||||
space_obj = bpy.data.objects.new("IfcSpace/Name", None)
|
||||
|
||||
@@ -154,15 +154,6 @@ class TestRunGeometryAddRepresntation(NewFile):
|
||||
pass
|
||||
|
||||
|
||||
class TestSetElementSpecificDisplaySettings(NewFile):
|
||||
def test_opening_elements_display_as_wire(self):
|
||||
ifc = ifcopenshell.file()
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
element = ifc.createIfcOpeningElement()
|
||||
subject.set_element_specific_display_settings(obj, element)
|
||||
assert obj.display_type == "WIRE"
|
||||
|
||||
|
||||
class TestSetObjectName(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
Reference in New Issue
Block a user