mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Fix bug where switching representations didn't update the material checksum, leading to unnecessary material syncs at export time.
This commit is contained in:
@@ -106,6 +106,7 @@ def switch_representation(
|
|||||||
data = existing_data
|
data = existing_data
|
||||||
|
|
||||||
geometry.change_object_data(obj, data, is_global=is_global)
|
geometry.change_object_data(obj, data, is_global=is_global)
|
||||||
|
geometry.record_object_materials(obj)
|
||||||
|
|
||||||
if should_reload and existing_data:
|
if should_reload and existing_data:
|
||||||
geometry.delete_data(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."""
|
otherwise it will replace object with empty."""
|
||||||
|
|
||||||
element = ifc.get_entity(obj)
|
element = ifc.get_entity(obj)
|
||||||
type = geometry.get_element_type(element)
|
element_type = geometry.get_element_type(element)
|
||||||
data = None
|
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)
|
representation = geometry.resolve_mapped_representation(representation)
|
||||||
data = geometry.get_representation_data(representation)
|
data = geometry.get_representation_data(representation)
|
||||||
if data and geometry.has_data_users(data):
|
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)
|
obj = ifc.get_object(element)
|
||||||
if obj:
|
if obj:
|
||||||
obj = geometry.replace_object_with_empty(obj)
|
obj = geometry.replace_object_with_empty(obj)
|
||||||
obj = ifc.get_object(type)
|
obj = ifc.get_object(element_type)
|
||||||
if obj:
|
if obj:
|
||||||
obj = geometry.replace_object_with_empty(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)
|
ifc.run("geometry.remove_representation", representation=representation)
|
||||||
else:
|
else:
|
||||||
data = geometry.get_representation_data(representation)
|
data = geometry.get_representation_data(representation)
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ class TestSwitchRepresentation:
|
|||||||
geometry.rename_object("new_data", "name").should_be_called()
|
geometry.rename_object("new_data", "name").should_be_called()
|
||||||
geometry.link("representation", "new_data").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.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()
|
geometry.clear_modifiers("obj").should_be_called()
|
||||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||||
geometry.clear_cache("element").should_be_called()
|
geometry.clear_cache("element").should_be_called()
|
||||||
@@ -222,6 +223,7 @@ class TestSwitchRepresentation:
|
|||||||
geometry.rename_object("new_data", "name").should_be_called()
|
geometry.rename_object("new_data", "name").should_be_called()
|
||||||
geometry.link("representation", "new_data").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.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.delete_data("existing_data").should_be_called()
|
||||||
geometry.clear_modifiers("obj").should_be_called()
|
geometry.clear_modifiers("obj").should_be_called()
|
||||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
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.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||||
geometry.change_object_data("obj", "data", is_global=True).should_be_called()
|
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()
|
geometry.clear_modifiers("obj").should_be_called()
|
||||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||||
geometry.clear_cache("element").should_be_called()
|
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.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||||
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
|
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()
|
geometry.clear_modifiers("obj").should_be_called()
|
||||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||||
geometry.clear_cache("element").should_be_called()
|
geometry.clear_cache("element").should_be_called()
|
||||||
|
|||||||
Reference in New Issue
Block a user