Fix #1375. Spatial zones as non-hierarchical entities are now supported.

This commit is contained in:
Dion Moult
2022-08-22 17:31:44 +10:00
parent f50e790b11
commit de6b578d9c
4 changed files with 34 additions and 5 deletions
+17 -1
View File
@@ -56,7 +56,7 @@ class TestAssign(NewFile):
assert len(wall_obj.users_collection) == 1
assert "IfcProject" in wall_obj.users_collection[0].name
def test_in_decomposition_mode_spatial_elements_are_placed_in_a_collection_of_the_same_name(self):
def test_in_decomposition_mode_spatial_structure_elements_are_placed_in_a_collection_of_the_same_name(self):
bpy.ops.bim.create_project()
space_obj = bpy.data.objects.new("IfcSpace/Name", None)
space_element = tool.Ifc.get().createIfcSpace()
@@ -72,6 +72,22 @@ 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_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)
space_element = tool.Ifc.get().createIfcSpatialZone()
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)
assert len(space_obj.users_collection) == 1
assert space_obj.users_collection[0].name != space_obj.name
def test_in_decomposition_mode_aggregates_are_placed_in_a_collection_of_the_same_name(self):
bpy.ops.bim.create_project()
element_obj = bpy.data.objects.new("IfcElementAssembly/Name", None)
+13 -2
View File
@@ -31,7 +31,7 @@ class TestImplementsTool(NewFile):
class TestCanContain(NewFile):
def test_a_spatial_element_can_contain_an_element(self):
def test_a_spatial_structure_element_can_contain_an_element(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
structure = ifc.createIfcSite()
@@ -42,7 +42,7 @@ class TestCanContain(NewFile):
tool.Ifc.link(element, element_obj)
assert subject.can_contain(structure_obj, element_obj) is True
def test_a_spatial_element_can_contain_an_element_ifc2x3(self):
def test_a_spatial_structure_element_can_contain_an_element_ifc2x3(self):
ifc = ifcopenshell.file(schema="IFC2X3")
tool.Ifc.set(ifc)
structure = ifc.createIfcSite()
@@ -53,6 +53,17 @@ class TestCanContain(NewFile):
tool.Ifc.link(element, element_obj)
assert subject.can_contain(structure_obj, element_obj) is True
def test_a_spatial_zone_element_cannot_contain_an_element(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
structure = ifc.createIfcSpatialZone()
structure_obj = bpy.data.objects.new("Object", None)
tool.Ifc.link(structure, structure_obj)
element = ifc.createIfcWall()
element_obj = bpy.data.objects.new("Object", None)
tool.Ifc.link(element, element_obj)
assert subject.can_contain(structure_obj, element_obj) is False
def test_unlinked_elements_cannot_contain_anything(self):
structure_obj = bpy.data.objects.new("Object", None)
element_obj = bpy.data.objects.new("Object", None)