From 2cc4f96b7f880b7677dea139dc10b60011f3f2c9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 7 Feb 2025 22:02:44 +1100 Subject: [PATCH] Fix failing project feature tests. Fix regression where appending an asset might append a named style twice. --- src/bonsai/test/bim/feature/project.feature | 13 +++++++------ .../ifcopenshell/api/project/append_asset.py | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bonsai/test/bim/feature/project.feature b/src/bonsai/test/bim/feature/project.feature index 11a3023340..392d58d280 100644 --- a/src/bonsai/test/bim/feature/project.feature +++ b/src/bonsai/test/bim/feature/project.feature @@ -802,10 +802,10 @@ Scenario: Toggle link visibility - visible mode And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')" When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.ifc', mode='VISIBLE')" Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_hidden" is "True" - And the collection "IfcProject/basic.ifc" exclude status is "True" + And the object "IfcProject/basic.ifc" is not visible When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.ifc', mode='VISIBLE')" Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_hidden" is "False" - And the collection "IfcProject/basic.ifc" exclude status is "False" + And the object "IfcProject/basic.ifc" is visible Scenario: Unload link Given an empty Blender session @@ -820,7 +820,7 @@ Scenario: Load link And I press "bim.unload_link(filepath='{cwd}/test/files/basic.ifc')" When I press "bim.load_link(filepath='{cwd}/test/files/basic.ifc')" Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_loaded" is "True" - And the collection "IfcProject/basic.ifc" exists in viewlayer + And the object "IfcProject/basic.ifc" exists Scenario: Unlink IFC Given an empty Blender session @@ -867,12 +867,13 @@ Scenario: Export IFC - with basic contents and saving as a relative path Given an empty Blender session And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')" When I press "wm.save_mainfile(filepath='{cwd}/test/files/temp/export.blend')" - And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc', use_relative_path=True, save_as_invoked=True)" + And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc', use_relative_path=True, should_save_as=True)" Then "scene.BIMProperties.ifc_file" is "export.ifc" Scenario: Export IFC - with deleted objects synchronised Given an empty IFC project When the object "IfcBuildingStorey/My Storey" is selected + And I set "scene.BIMSpatialDecompositionProperties.is_locked" to "False" And I delete the selected objects And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started @@ -896,7 +897,7 @@ Scenario: Export IFC - with moved grid axis location synchronised And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the object "IfcGridAxis/01" bottom left corner is at "1,-2,0" -Scenario: Export IFC - with changed object scale synchronised +Scenario: Export IFC - with changed object scale ignored Given an empty IFC project And I add a cube And the object "Cube" is selected @@ -908,4 +909,4 @@ Scenario: Export IFC - with changed object scale synchronised And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" - Then the object "IfcWall/Cube" dimensions are "4,4,4" + Then the object "IfcWall/Cube" dimensions are "2,2,2" diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py index f99d5238de..aca33128aa 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py @@ -220,13 +220,16 @@ class Usecase: elif not self.assume_asset_uniqueness_by_name: return None elif element.is_a("IfcMaterial"): - material_name = element.Name - return next((e for e in self.file.by_type("IfcMaterial") if e.Name == material_name), None) + name = element.Name + return next((e for e in self.file.by_type("IfcMaterial") if e.Name == name), None) elif element.is_a("IfcProfileDef"): profile_name = element.ProfileName if profile_name is None: return None return next((e for e in self.file.by_type("IfcProfileDef") if e.ProfileName == profile_name), None) + elif element.is_a("IfcPresentationStyle"): + name = element.Name + return next((e for e in self.file.by_type("IfcPresentationStyle") if e.Name == name), None) else: return None