From 2845071621e00689ee3b16490b98a64019bccb25 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 13 Nov 2024 17:26:51 +0500 Subject: [PATCH] Fix error switching from different type of representations E.g. from curve representation to mesh representation and vice versa. Mentioned in #5687. --- src/bonsai/bonsai/tool/geometry.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index 532fd0fccc..e7e5e4eaff 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -747,7 +747,10 @@ class Geometry(bonsai.core.tool.Geometry): meshes[mesh_name] = mesh old_mesh = obj.data - cls.change_object_data(obj, mesh, is_global=False) + if type(old_mesh) == type(mesh): + cls.change_object_data(obj, mesh, is_global=False) + else: + obj = cls.recreate_object_with_data(obj, mesh, is_global=False) cls.record_object_materials(obj) if not cls.has_data_users(old_mesh): cls.delete_data(old_mesh) @@ -778,7 +781,10 @@ class Geometry(bonsai.core.tool.Geometry): meshes[mesh_name] = mesh old_mesh = obj.data - cls.change_object_data(obj, mesh, is_global=False) + if type(old_mesh) == type(mesh): + cls.change_object_data(obj, mesh, is_global=False) + else: + obj = cls.recreate_object_with_data(obj, mesh, is_global=False) cls.record_object_materials(obj) if not cls.has_data_users(old_mesh): cls.delete_data(old_mesh)