From 1413cf4f9d5b06c82add64ca79339d727c8c78a0 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 19 Jul 2022 09:46:16 +1000 Subject: [PATCH] Fix bug when adding material sets to a non parametric object --- .../blenderbim/bim/module/model/product.py | 5 +++- .../test/bim/feature/material.feature | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index 6a383c6d41..20c948d4e3 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -340,10 +340,13 @@ def ensure_material_assigned(usecase_path, ifc_file, settings): if om is not None and om.BIMObjectProperties.ifc_definition_id ] - if material[0].id() in object_material_ids: + if material and material[0].id() in object_material_ids: continue if len(obj.data.materials) == 1: obj.data.materials.clear() + if not material: + continue + obj.data.materials.append(IfcStore.get_element(material[0].id())) diff --git a/src/blenderbim/test/bim/feature/material.feature b/src/blenderbim/test/bim/feature/material.feature index c3d89dbbb1..eef195f731 100644 --- a/src/blenderbim/test/bim/feature/material.feature +++ b/src/blenderbim/test/bim/feature/material.feature @@ -111,6 +111,33 @@ Scenario: Assign material - Assign a material profile set And I press "bim.assign_material" Then nothing happens +Scenario: Assign material - Assign a material profile set + 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='')" + When I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialProfileSet" + And I press "bim.assign_material" + Then nothing happens + +Scenario: Assign material - Assign a material constituent set + 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 press "bim.add_material(obj='')" + When I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialConstituentSet" + And I press "bim.assign_material" + Then nothing happens + Scenario: Select by material Given an empty IFC project And I press "bim.load_materials"