From 090c670f040c8a6bd883c2010a932ce61f0cef7b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 14 Oct 2024 15:24:42 +0500 Subject: [PATCH] avoid reimport representation meshes having .001 suffixes --- src/bonsai/bonsai/bim/import_ifc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index 7cb45c721d..a9d3451d07 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -1090,7 +1090,12 @@ class IfcImporter: else: geometry = shape - mesh = bpy.data.meshes.new(tool.Loader.get_mesh_name_from_shape(geometry)) + # Mesh may already exists (e.g. during representation reimport) + # and we assign some suffix to it to prevent Blender from adding '.001' suffix to the new mesh. + mesh_name = tool.Loader.get_mesh_name_from_shape(geometry) + if old_mesh := bpy.data.meshes.get(mesh_name): + old_mesh.name = mesh_name + ".old" + mesh = bpy.data.meshes.new(mesh_name) if cartesian_point_offset is False: verts = geometry.verts