Swapping a Blender material for another is now auto synchronised.

This commit is contained in:
Dion Moult
2021-11-11 18:21:02 +11:00
parent 6f55cd5169
commit 2ec3c4c06b
11 changed files with 59 additions and 5 deletions
@@ -401,3 +401,18 @@ Scenario: Export IFC - with changed style colour synchronised
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"
Scenario: Export IFC - with changed style element 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 I add a material
And the material "Material.001" 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.001" colour is "1,0,0,1"
+1
View File
@@ -91,6 +91,7 @@ def i_add_a_sun():
@given("I add a material")
@when("I add a material")
def i_add_a_material():
bpy.context.active_object.active_material = bpy.data.materials.new("Material")
@@ -74,6 +74,7 @@ class TestAddRepresentation:
styles=["style"],
should_use_presentation_style_assignment=False,
).should_be_called()
geometry.record_object_materials("obj").should_be_called()
# Assign representation to product
ifc.run("geometry.assign_representation", product="element", representation="representation").should_be_called()
+13
View File
@@ -352,6 +352,19 @@ class TestLink(NewFile):
assert obj.BIMMeshProperties.ifc_definition_id == element.id()
class TestRecordObjectMaterials(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
style = ifc.createIfcSurfaceStyle()
material = bpy.data.materials.new("Material")
material.BIMMaterialProperties.ifc_style_id = style.id()
obj.data.materials.append(material)
subject.record_object_materials(obj)
assert obj.data.BIMMeshProperties.material_checksum == str([style.id()])
class TestRecordObjectPosition(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)