Fix bug where style colours were not auto synchronised.

This commit is contained in:
Dion Moult
2021-11-11 14:18:44 +11:00
parent 9355969110
commit d5b92c0fea
13 changed files with 106 additions and 49 deletions
@@ -387,3 +387,17 @@ Scenario: Export IFC - with changed object scale synchronised
And an empty Blender session is started
And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')"
Then the object "IfcWall/Cube" dimensions are "4,4,4"
Scenario: Export IFC - with changed style colour synchronised
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I add a material
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
When the material "Material" colour is set to "1,0,0,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 material "Material" colour is "1,0,0,1"
+14
View File
@@ -95,6 +95,14 @@ def i_add_a_material():
bpy.context.active_object.active_material = bpy.data.materials.new("Material")
@given(parsers.parse('the material "{name}" colour is set to "{colour}"'))
@when(parsers.parse('the material "{name}" colour is set to "{colour}"'))
def the_material_name_colour_is_set_to_colour(name, colour):
obj = the_material_name_exists(name)
obj.diffuse_color = [float(c) for c in colour.split(",")]
blenderbim.bim.handler.color_callback(obj, None)
@given("I add an array modifier")
def i_add_a_cube():
bpy.ops.object.modifier_add(type="ARRAY")
@@ -385,6 +393,12 @@ def the_material_name_is_not_an_ifc_material(name):
assert id == 0, f"The ID is {id}"
@then(parsers.parse('the material "{name}" colour is "{colour}"'))
def the_material_name_colour_is_set_to_colour(name, colour):
diffuse_color = list(the_material_name_exists(name).diffuse_color)
assert diffuse_color == [float(c) for c in colour.split(",")], f"The colour is {diffuse_color}"
@then(parsers.parse('the object "{name}" has "{number}" vertices'))
def the_object_name_has_number_vertices(name, number):
total = len(the_object_name_exists(name).data.vertices)