Fix failing model tests and regression 0899a2a8 where switching geometry can invalidate old meshes

The fix in 0899a2a8 ensured that when you switched geometry, all other
elements (sharing the same type or representation) would also switch
alongside it. However it would lead to mesh invalidation which broke
some assumptions in the style code. The style code also repeated a lot
of the logic of switch representation (i.e. finding shared
representations) so this seems simpler.

In general the whole representation part of the code is messy and
hopefully over time it'll get better.
This commit is contained in:
Dion Moult
2025-02-07 12:35:08 +11:00
parent e603ebed04
commit 4c255cca43
3 changed files with 14 additions and 120 deletions
+1 -1
View File
@@ -101,7 +101,6 @@ class TestGetManualBooleans(NewFile):
assert len(subject.get_manual_booleans(element, representation)) == 0
bool1 = list(bools)[0]
print(bools, bool1)
subject.mark_manual_booleans(element, [bool1])
assert set(subject.get_manual_booleans(element, representation)) == {bool1}
@@ -638,6 +637,7 @@ class TestApplyIfcMaterialChanges(NewFile):
ifcopenshell.api.material.assign_material(ifc_file, products=[element], material=red_material)
tool.Material.ensure_material_assigned([element], material=red_material)
mesh = self.get_mesh(obj)
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")}