From 40560b71c217a17a01511d74deef9f8dca79a2aa Mon Sep 17 00:00:00 2001 From: Sigma Dimensions <79010126+myoualid@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:49:54 +0100 Subject: [PATCH] BBIM: fix material errors, and add smoke tests --- .../bim/module/material/operator.py | 6 +-- .../test/bim/feature/material.feature | 45 ++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/material/operator.py b/src/blenderbim/blenderbim/bim/module/material/operator.py index 25ccd29d4d..109ad46f0b 100644 --- a/src/blenderbim/blenderbim/bim/module/material/operator.py +++ b/src/blenderbim/blenderbim/bim/module/material/operator.py @@ -242,7 +242,7 @@ class RemoveConstituent(bpy.types.Operator, tool.Ifc.Operator): constituent: bpy.props.IntProperty() def _execute(self, context): - for inverse in tool.Ifc.get().get_inverse(layer): + for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.constituent)): if inverse.is_a("IfcMaterialConstituentSet") and len(inverse.MaterialConstituents) == 1: return ifcopenshell.api.run( @@ -277,7 +277,7 @@ class RemoveProfile(bpy.types.Operator, tool.Ifc.Operator): profile: bpy.props.IntProperty() def _execute(self, context): - for inverse in tool.Ifc.get().get_inverse(layer): + for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.profile)): if inverse.is_a("IfcMaterialProfileSet") and len(inverse.MaterialProfiles) == 1: return ifcopenshell.api.run("material.remove_profile", tool.Ifc.get(), profile=tool.Ifc.get().by_id(self.profile)) @@ -335,7 +335,7 @@ class RemoveLayer(bpy.types.Operator, tool.Ifc.Operator): layer: bpy.props.IntProperty() def _execute(self, context): - for inverse in tool.Ifc.get().get_inverse(layer): + for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.layer)): if inverse.is_a("IfcMaterialLayerSet") and len(inverse.MaterialLayers) == 1: return ifcopenshell.api.run("material.remove_layer", tool.Ifc.get(), layer=tool.Ifc.get().by_id(self.layer)) diff --git a/src/blenderbim/test/bim/feature/material.feature b/src/blenderbim/test/bim/feature/material.feature index 4c40c05019..8b5127edd7 100644 --- a/src/blenderbim/test/bim/feature/material.feature +++ b/src/blenderbim/test/bim/feature/material.feature @@ -396,7 +396,7 @@ Scenario: Contract material category When I press "bim.contract_material_category(category='')" Then nothing happens -Scenario: Enable Editing Material set Item +Scenario: Enable editing material set item Given an empty IFC project And I load the demo construction library When I set "scene.BIMModelProperties.ifc_class" to "IfcColumnType" @@ -407,4 +407,45 @@ Scenario: Enable Editing Material set Item And the variable "relating_material" is "{ifc}.by_id({column_type}).HasAssociations[0].RelatingMaterial.id()" And the variable "material_profile" is "{ifc}.by_id({column_type}).HasAssociations[0].RelatingMaterial.MaterialProfiles[0].id()" And I press "bim.enable_editing_assigned_material" - And I press "bim.enable_editing_material_set_item(material_set_item={material_profile})" \ No newline at end of file + When I press "bim.enable_editing_material_set_item(material_set_item={material_profile})" + Then nothing happens + +Scenario: Add material set layer + 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 I add an empty + And the object "Empty" is selected + And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" + And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" + And I press "bim.assign_class" + And I press "bim.add_material(obj='')" + And I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialLayerSet" + And I press "bim.assign_material" + And I press "bim.enable_editing_assigned_material" + And the variable "material_set" is "{ifc}.by_type('IfcMaterialLayerSet')[0].id()" + When I press "bim.add_layer(layer_set={material_set})" + Then nothing happens + +Scenario: Remove material set layer + 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 I add an empty + And the object "Empty" is selected + And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" + And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" + And I press "bim.assign_class" + And I press "bim.add_material(obj='')" + And I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialLayerSet" + And I press "bim.assign_material" + And I press "bim.enable_editing_assigned_material" + And the variable "material_set" is "{ifc}.by_type('IfcMaterialLayerSet')[0].id()" + And I press "bim.remove_layer(layer={ifc}.by_id({material_set}).MaterialLayers[0].id())" + And I press "bim.add_layer(layer_set={material_set})" + When I press "bim.remove_layer(layer={ifc}.by_id({material_set}).MaterialLayers[0].id())" + Then nothing happens \ No newline at end of file