mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-01 17:36:27 +00:00
Objects now sync spatial hierarchy more robustly on export, and clean the collection tree in case the user messed it up.
This commit is contained in:
@@ -104,6 +104,7 @@ Scenario: Load project elements - load objects filtered by decomposition
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
|
||||
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
|
||||
And I set "scene.BIMProjectProperties.filter_mode" to "DECOMPOSITION"
|
||||
And I set "scene.BIMProjectProperties.should_filter_spatial_elements" to "True"
|
||||
Then "scene.BIMProjectProperties.filter_categories['IfcSite/My Site'].total_elements" is "0"
|
||||
Then "scene.BIMProjectProperties.filter_categories['IfcBuilding/My Building'].total_elements" is "0"
|
||||
Then "scene.BIMProjectProperties.filter_categories['IfcBuildingStorey/Ground Floor'].total_elements" is "1"
|
||||
@@ -131,6 +132,7 @@ Scenario: Load project elements - load objects filtered by IFC class
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
|
||||
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
|
||||
And I set "scene.BIMProjectProperties.filter_mode" to "IFC_CLASS"
|
||||
And I set "scene.BIMProjectProperties.should_filter_spatial_elements" to "True"
|
||||
Then "scene.BIMProjectProperties.filter_categories['IfcWall'].total_elements" is "1"
|
||||
And "scene.BIMProjectProperties.filter_categories['IfcSlab'].total_elements" is "1"
|
||||
And "scene.BIMProjectProperties.filter_categories['IfcElementAssembly'].total_elements" is "1"
|
||||
@@ -155,6 +157,7 @@ Scenario: Load project elements - load objects filtered by whitelist
|
||||
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
|
||||
And I set "scene.BIMProjectProperties.filter_mode" to "WHITELIST"
|
||||
And I set "scene.BIMProjectProperties.filter_query" to ".IfcSlab"
|
||||
And I set "scene.BIMProjectProperties.should_filter_spatial_elements" to "True"
|
||||
And I press "bim.load_project_elements"
|
||||
Then the object "IfcProject/My Project" is an "IfcProject"
|
||||
And the object "IfcSite/My Site" is an "IfcSite"
|
||||
@@ -174,6 +177,7 @@ Scenario: Load project elements - load objects filtered by blacklist
|
||||
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
|
||||
And I set "scene.BIMProjectProperties.filter_mode" to "BLACKLIST"
|
||||
And I set "scene.BIMProjectProperties.filter_query" to ".IfcSlab"
|
||||
And I set "scene.BIMProjectProperties.should_filter_spatial_elements" to "True"
|
||||
And I press "bim.load_project_elements"
|
||||
Then the object "IfcProject/My Project" is an "IfcProject"
|
||||
And the object "IfcSite/My Site" is an "IfcSite"
|
||||
@@ -196,6 +200,7 @@ Scenario: Load project elements - load no objects due to filter
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
|
||||
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
|
||||
And I set "scene.BIMProjectProperties.filter_mode" to "IFC_CLASS"
|
||||
And I set "scene.BIMProjectProperties.should_filter_spatial_elements" to "True"
|
||||
And I press "bim.load_project_elements"
|
||||
Then the object "IfcProject/My Project" is an "IfcProject"
|
||||
And the object "IfcSite/My Site" does not exist
|
||||
@@ -325,7 +330,7 @@ Scenario: Export IFC - with moved object location synchronised
|
||||
Given an empty IFC project
|
||||
When the object "IfcBuildingStorey/My Storey" is moved to "0,0,1"
|
||||
And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')"
|
||||
And an empty Blender session
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')"
|
||||
Then the object "IfcBuildingStorey/My Storey" is at "0,0,1"
|
||||
|
||||
@@ -334,6 +339,16 @@ Scenario: Export IFC - with moved grid axis location synchronised
|
||||
And I press "mesh.add_grid"
|
||||
When the object "IfcGridAxis/01" is moved to "1,0,0"
|
||||
And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')"
|
||||
And an empty Blender session
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')"
|
||||
Then the object "IfcGridAxis/01" bottom left corner is at "1,-2,0"
|
||||
|
||||
Scenario: Export IFC - with changed spatial container synchronised
|
||||
Given an empty Blender session
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
|
||||
Then the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor"
|
||||
When the object "IfcSlab/Slab" is placed in the collection "IfcBuildingStorey/Level 1"
|
||||
And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')"
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')"
|
||||
Then the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Level 1"
|
||||
|
||||
@@ -41,7 +41,7 @@ def replace_variables(value):
|
||||
|
||||
|
||||
@given("an empty Blender session")
|
||||
@when("an empty Blender session")
|
||||
@when("an empty Blender session is started")
|
||||
def an_empty_ifc_project():
|
||||
IfcStore.purge()
|
||||
bpy.ops.wm.read_homefile(app_template="")
|
||||
|
||||
@@ -214,3 +214,25 @@ class TestAssign(NewFile):
|
||||
subject.assign(axis_obj)
|
||||
assert axis_obj.users_collection[0].name == "UAxes"
|
||||
assert bpy.data.collections.get("IfcGrid/Name").children.get("UAxes")
|
||||
|
||||
|
||||
class TestSync(NewFile):
|
||||
def test_in_decomposition_mode_elements_can_be_in_spatial_containers(self):
|
||||
bpy.ops.bim.create_project()
|
||||
wall_obj = bpy.data.objects.new("Object", None)
|
||||
wall_element = tool.Ifc.get().createIfcWall()
|
||||
tool.Ifc.link(wall_element, wall_obj)
|
||||
bpy.data.collections.get("IfcSite/My Site").objects.link(wall_obj)
|
||||
subject.sync(wall_obj)
|
||||
assert ifcopenshell.util.element.get_container(wall_element).is_a("IfcSite")
|
||||
|
||||
def test_in_decomposition_mode_elements_can_aggregate(self):
|
||||
bpy.ops.bim.create_project()
|
||||
obj = bpy.data.objects.new("IfcBuildingStorey/Name", None)
|
||||
col = bpy.data.collections.new("IfcBuildingStorey/Name")
|
||||
element = tool.Ifc.get().createIfcBuildingStorey(Name="Name")
|
||||
tool.Ifc.link(element, obj)
|
||||
bpy.data.collections.get("IfcBuilding/My Building").children.link(col)
|
||||
col.objects.link(obj)
|
||||
subject.sync(obj)
|
||||
assert ifcopenshell.util.element.get_aggregate(element).is_a("IfcBuilding")
|
||||
|
||||
Reference in New Issue
Block a user