From 3d86e5fff3a524fbd946a726593d174a0cddedb3 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 31 Jul 2024 13:17:36 +0500 Subject: [PATCH] fix bim geometry tests after fccf56d --- src/blenderbim/blenderbim/core/geometry.py | 7 +++++-- src/blenderbim/blenderbim/tool/geometry.py | 1 + .../test/bim/feature/geometry.feature | 18 ++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/blenderbim/blenderbim/core/geometry.py b/src/blenderbim/blenderbim/core/geometry.py index 63ba4e6961..9c46822dee 100644 --- a/src/blenderbim/blenderbim/core/geometry.py +++ b/src/blenderbim/blenderbim/core/geometry.py @@ -169,8 +169,11 @@ def get_representation_ifc_parameters( def remove_representation( ifc: tool.Ifc, geometry: tool.Geometry, obj: bpy.types.Object, representation: ifcopenshell.entity_instance ) -> None: - """Consider changing obj representation before using the function, - otherwise it will replace object with empty.""" + """Remove IFC representation from an object. + + If removed representation is active will automatically change it to some other one. + If it is the object's only representation, object will be recreated as an empty. + """ element = ifc.get_entity(obj) assert element diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 780e815ee5..31603a50f4 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -927,6 +927,7 @@ class Geometry(blenderbim.core.tool.Geometry): new_representation = None for r in cls.get_representations_iter(element): + r = tool.Geometry.resolve_mapped_representation(r) if r != representation: new_representation = r break diff --git a/src/blenderbim/test/bim/feature/geometry.feature b/src/blenderbim/test/bim/feature/geometry.feature index c5f23f4819..663544196d 100644 --- a/src/blenderbim/test/bim/feature/geometry.feature +++ b/src/blenderbim/test/bim/feature/geometry.feature @@ -131,8 +131,10 @@ Scenario: Remove representation - remove an active representation And I set "scene.BIMRootProperties.ifc_product" to "IfcElement" And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" - When the variable "representation" is "{ifc}.by_type('IfcShapeRepresentation')[0].id()" - And I press "bim.remove_representation(representation_id={representation})" + When the variable "representation_body" is "{ifc}.by_type('IfcShapeRepresentation')[0].id()" + And the variable "representation_bbox" is "{ifc}.by_type('IfcShapeRepresentation')[1].id()" + And I press "bim.remove_representation(representation_id={representation_body})" + And I press "bim.remove_representation(representation_id={representation_bbox})" Then the object "IfcWall/Cube" has no data Scenario: Remove representation - remove an unloaded representation @@ -160,8 +162,10 @@ Scenario: Remove representation - remove an instanced representation from an act And I press "bim.add_constr_type_instance" And I press "bim.add_constr_type_instance" And the object "IfcWallType/Cube" is selected - When the variable "representation" is "{ifc}.by_type('IfcWallType')[0].RepresentationMaps[1].MappedRepresentation.id()" - And I press "bim.remove_representation(representation_id={representation})" + When the variable "representation_body" is "{ifc}.by_type('IfcWallType')[0].RepresentationMaps[1].MappedRepresentation.id()" + And the variable "representation_bbox" is "{ifc}.by_type('IfcWallType')[0].RepresentationMaps[0].MappedRepresentation.id()" + And I press "bim.remove_representation(representation_id={representation_body})" + And I press "bim.remove_representation(representation_id={representation_bbox})" Then the object "IfcWallType/Cube" has no data Then the object "IfcWall/Wall" has no data Then the object "IfcWall/Wall.001" has no data @@ -179,8 +183,10 @@ Scenario: Remove representation - remove an instanced representation from an act And I press "bim.add_constr_type_instance" And I press "bim.add_constr_type_instance" And the object "IfcWall/Wall" is selected - When the variable "representation" is "{ifc}.by_type('IfcWall')[0].Representation.Representations[1].id()" - And I press "bim.remove_representation(representation_id={representation})" + When the variable "representation_body" is "{ifc}.by_type('IfcWall')[0].Representation.Representations[1].id()" + And the variable "representation_bbox" is "{ifc}.by_type('IfcWall')[0].Representation.Representations[0].id()" + And I press "bim.remove_representation(representation_id={representation_body})" + And I press "bim.remove_representation(representation_id={representation_bbox})" Then the object "IfcWallType/Cube" has no data Then the object "IfcWall/Wall" has no data Then the object "IfcWall/Wall.001" has no data