Fix bug when adding material sets to a non parametric object

This commit is contained in:
Dion Moult
2022-07-19 09:46:16 +10:00
parent d71ebb8d25
commit 1413cf4f9d
2 changed files with 31 additions and 1 deletions
@@ -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()))
@@ -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"