remove bbim material unassignment listener #4843

Listeners are implicit and get in the way sometimes, we should work on our core methods and make explicit calls.
This commit is contained in:
Andrej730
2024-07-05 17:36:07 +05:00
parent 7a89d8f5ed
commit 8a9ca9ac60
6 changed files with 40 additions and 36 deletions
+5
View File
@@ -546,6 +546,7 @@ class TestApplyIfcMaterialChanges(NewFile):
assert self.get_used_styles(obj) == expected
ifcopenshell.api.material.unassign_material(ifc_file, products=[element_type])
tool.Material.ensure_material_unassigned([element_type])
assert self.get_used_styles(tool.Ifc.get_object(element_type)) == set()
for element in ifc_file.by_type("IfcActuator"):
obj = tool.Ifc.get_object(element)
@@ -573,6 +574,7 @@ class TestApplyIfcMaterialChanges(NewFile):
assert self.get_used_styles(obj) == {green_style}
ifcopenshell.api.material.unassign_material(ifc_file, products=[element_type])
tool.Material.ensure_material_unassigned([element_type])
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 +615,7 @@ class TestApplyIfcMaterialChanges(NewFile):
ifcopenshell.api.material.assign_material(ifc_file, products=[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])
mesh = self.get_mesh(obj)
assert len(mesh.materials) == 2
assert set(mesh.materials) == {bpy.data.materials["Green"], None}
@@ -630,6 +633,7 @@ class TestApplyIfcMaterialChanges(NewFile):
assert set(get_material_indices(mesh)) == {mesh.materials.find("Red")}
ifcopenshell.api.material.unassign_material(ifc_file, products=[element])
tool.Material.ensure_material_unassigned([element])
mesh = self.get_mesh(obj)
assert len(mesh.materials) == 2
assert set(mesh.materials) == {bpy.data.materials["Red"], None}
@@ -651,4 +655,5 @@ class TestApplyIfcMaterialChanges(NewFile):
assert self.get_mesh(obj).materials[:] == []
ifcopenshell.api.material.unassign_material(ifc_file, products=[element])
tool.Material.ensure_material_unassigned([element])
assert self.get_mesh(obj).materials[:] == [bpy.data.materials["Red"]]