From f0502c123ea61c5574a7cb0d8e293afc94c4ec1e Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 8 Feb 2023 18:17:47 +0500 Subject: [PATCH] Window modifier - fixed bugs related to ae5ea3857 1) now replacing actual representation instead of the map 2) removed `should_sync_changes_first` as unnecessary representation update --- .../blenderbim/bim/module/model/helper.py | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/helper.py b/src/blenderbim/blenderbim/bim/module/model/helper.py index 99110ea9f5..fb462e93ee 100644 --- a/src/blenderbim/blenderbim/bim/module/model/helper.py +++ b/src/blenderbim/blenderbim/bim/module/model/helper.py @@ -45,23 +45,8 @@ def replace_ifc_representation_for_object(ifc_file, ifc_context, obj, new_repres ifc_element, ifc_context.ContextType, ifc_context.ContextIdentifier, ifc_context.TargetView ) - def switch_to_new_representation(): - core.switch_representation( - tool.Ifc, - tool.Geometry, - obj=obj, - representation=new_representation, - should_reload=True, - is_global=True, - should_sync_changes_first=True, - ) - if old_representation: - # switch should happen before `remove_representation` to make sure that - # no elements is using old representation - # otherwise `remove_representation` will replace them with empty objects - # and will lead to errors - switch_to_new_representation() + old_representation = tool.Geometry.resolve_mapped_representation(old_representation) for inverse in ifc_file.get_inverse(old_representation): ifcopenshell.util.element.replace_attribute(inverse, old_representation, new_representation) core.remove_representation(tool.Ifc, tool.Geometry, obj=obj, representation=old_representation) @@ -69,6 +54,14 @@ def replace_ifc_representation_for_object(ifc_file, ifc_context, obj, new_repres ifcopenshell.api.run( "geometry.assign_representation", ifc_file, product=ifc_element, representation=new_representation ) - switch_to_new_representation() - + core.switch_representation( + tool.Ifc, + tool.Geometry, + obj=obj, + representation=new_representation, + should_reload=True, + is_global=True, + should_sync_changes_first=False, + ) +