diff --git a/src/blenderbim/blenderbim/core/geometry.py b/src/blenderbim/blenderbim/core/geometry.py index 7f91fd15bc..42a05216a0 100644 --- a/src/blenderbim/blenderbim/core/geometry.py +++ b/src/blenderbim/blenderbim/core/geometry.py @@ -106,10 +106,13 @@ def switch_representation( entity = ifc.get_entity(obj) current_obj_data = obj.data - # doesn't resolve mapped representations in case if it's going to have openings - # otherwise we would also add openings to the type and other occurences mesh data has_openings = apply_openings and getattr(entity, "HasOpenings", None) - if not has_openings: + if has_openings: + # if it has openings make sure to switch to element's mapped representation + representation = geometry.unresolve_type_representation(representation, entity) + else: + # doesn't resolve mapped representations in case if it's going to have openings + # otherwise we would also add openings to the type and other occurences mesh data representation = geometry.resolve_mapped_representation(representation) old_repr_data = geometry.get_representation_data(representation) diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 8ca65ab73c..5dfc29e69a 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -631,6 +631,18 @@ class Geometry(blenderbim.core.tool.Geometry): return cls.resolve_mapped_representation(representation.Items[0].MappingSource.MappedRepresentation) return representation + @classmethod + def unresolve_type_representation(cls, representation, occurence): + if not ifcopenshell.util.element.get_type(occurence): + return representation + + if representation.RepresentationType == "MappedRepresentation": + return representation + + for mapped_representation in occurence.Representation.Representations: + if cls.resolve_mapped_representation(mapped_representation) == representation: + return mapped_representation + @classmethod def run_geometry_update_representation(cls, obj=None): bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")