Fix bug where switching representations didn't update the material checksum, leading to unnecessary material syncs at export time.

This commit is contained in:
Dion Moult
2023-04-13 18:15:28 +10:00
parent 07badd3df5
commit 3628a0e241
2 changed files with 10 additions and 5 deletions
+6 -5
View File
@@ -106,6 +106,7 @@ def switch_representation(
data = existing_data
geometry.change_object_data(obj, data, is_global=is_global)
geometry.record_object_materials(obj)
if should_reload and existing_data:
geometry.delete_data(existing_data)
@@ -123,20 +124,20 @@ def remove_representation(ifc, geometry, obj=None, representation=None):
otherwise it will replace object with empty."""
element = ifc.get_entity(obj)
type = geometry.get_element_type(element)
element_type = geometry.get_element_type(element)
data = None
if type and (geometry.is_mapped_representation(representation) or geometry.is_type_product(element)):
if element_type and (geometry.is_mapped_representation(representation) or geometry.is_type_product(element)):
representation = geometry.resolve_mapped_representation(representation)
data = geometry.get_representation_data(representation)
if data and geometry.has_data_users(data):
for element in geometry.get_elements_of_type(type):
for element in geometry.get_elements_of_type(element_type):
obj = ifc.get_object(element)
if obj:
obj = geometry.replace_object_with_empty(obj)
obj = ifc.get_object(type)
obj = ifc.get_object(element_type)
if obj:
obj = geometry.replace_object_with_empty(obj)
ifc.run("geometry.unassign_representation", product=type, representation=representation)
ifc.run("geometry.unassign_representation", product=element_type, representation=representation)
ifc.run("geometry.remove_representation", representation=representation)
else:
data = geometry.get_representation_data(representation)
@@ -199,6 +199,7 @@ class TestSwitchRepresentation:
geometry.rename_object("new_data", "name").should_be_called()
geometry.link("representation", "new_data").should_be_called()
geometry.change_object_data("obj", "new_data", is_global=True).should_be_called()
geometry.record_object_materials("obj").should_be_called()
geometry.clear_modifiers("obj").should_be_called()
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.clear_cache("element").should_be_called()
@@ -222,6 +223,7 @@ class TestSwitchRepresentation:
geometry.rename_object("new_data", "name").should_be_called()
geometry.link("representation", "new_data").should_be_called()
geometry.change_object_data("obj", "new_data", is_global=True).should_be_called()
geometry.record_object_materials("obj").should_be_called()
geometry.delete_data("existing_data").should_be_called()
geometry.clear_modifiers("obj").should_be_called()
ifc.get_entity("obj").should_be_called().will_return("element")
@@ -242,6 +244,7 @@ class TestSwitchRepresentation:
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
geometry.get_representation_data("representation").should_be_called().will_return("data")
geometry.change_object_data("obj", "data", is_global=True).should_be_called()
geometry.record_object_materials("obj").should_be_called()
geometry.clear_modifiers("obj").should_be_called()
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.clear_cache("element").should_be_called()
@@ -264,6 +267,7 @@ class TestSwitchRepresentation:
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
geometry.get_representation_data("representation").should_be_called().will_return("data")
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
geometry.record_object_materials("obj").should_be_called()
geometry.clear_modifiers("obj").should_be_called()
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.clear_cache("element").should_be_called()