Fix #1872. Bug where duplicating an object didn't duplicate its styles.

This commit is contained in:
Dion Moult
2021-11-11 14:51:05 +11:00
parent d5b92c0fea
commit f5f88f4b97
6 changed files with 49 additions and 6 deletions
@@ -309,6 +309,23 @@ Scenario: Override duplicate move - with active IFC data
And the object "IfcBuildingStorey/My Storey.001" exists
And the object "IfcBuildingStorey/My Storey.001" is an "IfcBuildingStorey"
Scenario: Override duplicate move - copying a coloured representation
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
And the material "Material" colour is set to "1,0,0,1"
When I press "object.duplicate_move"
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"
And the object "IfcWall/Cube" has the material "Material"
And the object "IfcWall/Cube.001" has the material "Material"
Scenario: Override duplicate move - copying a type instance with a representation map
Given an empty IFC project
And I add a cube
+2 -1
View File
@@ -62,7 +62,8 @@ class TestAddRepresentation:
# Add styles
geometry.get_object_materials_without_styles("obj").should_be_called().will_return(["material"])
test.core.test_style.TestAddStyle.predict(self, ifc, style, obj="material")
geometry.run_style_add_style(obj="material").should_be_called()
geometry.get_styles("obj").should_be_called().will_return(["style"])
# Link style to representation items
geometry.should_use_presentation_style_assignment().should_be_called().will_return(False)
+17
View File
@@ -169,6 +169,18 @@ class TestGetRepresentationName(NewFile):
assert subject.get_representation_name(representation) == f"{context.id()}/{representation.id()}"
class TestGetStyles(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
style = ifc.createIfcSurfaceStyle()
material = bpy.data.materials.new("Material")
tool.Ifc.link(style, material)
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
obj.data.materials.append(material)
subject.get_styles(obj) == [style]
class TestGetCartesianPointCoordinateOffset(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)
@@ -387,6 +399,11 @@ class TestRunGeometryUpdateRepresentation(NewFile):
pass
class TestRunStyleAddStyle(NewFile):
def test_nothing(self):
pass
class TestShouldForceFacetedBrep(NewFile):
def test_run(self):
result = bpy.context.scene.BIMGeometryProperties.should_force_faceted_brep