remove material assignment listener #4843

This commit is contained in:
Andrej730
2024-07-08 15:23:13 +05:00
parent 24c4858570
commit dd561d3703
5 changed files with 49 additions and 46 deletions
+7
View File
@@ -523,6 +523,7 @@ class TestApplyIfcMaterialChanges(NewFile):
ifcopenshell.api.material.assign_material(
ifc_file, products=[tool.Ifc.get_entity(with_material)], material=blue_material
)
tool.Material.ensure_material_assigned([tool.Ifc.get_entity(with_material)], material=blue_material)
assert self.get_used_styles(element_type_obj) == set()
for element in ifc_file.by_type("IfcActuator"):
@@ -539,6 +540,7 @@ class TestApplyIfcMaterialChanges(NewFile):
blue_style = next((i for i in ifc_file.by_type("IfcSurfaceStyle") if i.Name == "Blue"))
ifcopenshell.api.material.assign_material(ifc_file, material=red_material, products=[element_type])
tool.Material.ensure_material_assigned([element_type], material=red_material)
assert self.get_used_styles(tool.Ifc.get_object(element_type)) == {red_style}
for element in ifc_file.by_type("IfcActuator"):
obj = tool.Ifc.get_object(element)
@@ -568,6 +570,7 @@ class TestApplyIfcMaterialChanges(NewFile):
bpy.ops.bim.assign_style_to_selected(style_id=green_style.id())
ifcopenshell.api.material.assign_material(ifc_file, material=red_material, products=[element_type])
tool.Material.ensure_material_assigned([element_type], material=red_material)
assert self.get_used_styles(tool.Ifc.get_object(element_type)) == {green_style}
for element in ifc_file.by_type("IfcActuator"):
obj = tool.Ifc.get_object(element)
@@ -613,6 +616,7 @@ class TestApplyIfcMaterialChanges(NewFile):
assert set(mesh.materials) == {bpy.data.materials["Green"], None}
ifcopenshell.api.material.assign_material(ifc_file, products=[element], material=red_material)
tool.Material.ensure_material_assigned([element], material=red_material)
assert self.get_used_styles(obj) == {green_style, red_style}
ifcopenshell.api.material.unassign_material(ifc_file, products=[element])
tool.Material.ensure_material_unassigned([element])
@@ -628,6 +632,7 @@ class TestApplyIfcMaterialChanges(NewFile):
assert set(mesh.materials) == {bpy.data.materials["Red"], None}
ifcopenshell.api.material.assign_material(ifc_file, products=[element], material=red_material)
tool.Material.ensure_material_assigned([element], material=red_material)
assert mesh.materials[:] == [bpy.data.materials["Red"]]
# All polygons are just reassigned to the existing material.
assert set(get_material_indices(mesh)) == {mesh.materials.find("Red")}
@@ -649,9 +654,11 @@ class TestApplyIfcMaterialChanges(NewFile):
element = tool.Ifc.get_entity(obj)
ifcopenshell.api.material.assign_material(ifc_file, material=red_material, products=[element_type])
tool.Material.ensure_material_assigned([element_type], material=red_material)
# Override type material.
ifcopenshell.api.material.assign_material(ifc_file, material=no_style_material, products=[element])
tool.Material.ensure_material_assigned([element], material=no_style_material)
assert self.get_mesh(obj).materials[:] == []
ifcopenshell.api.material.unassign_material(ifc_file, products=[element])