From d5bcaaf18be4926a8cf5a56e5cc4d3e73a1014d2 Mon Sep 17 00:00:00 2001 From: ElgoogUdiab Date: Fri, 28 Mar 2025 13:23:17 +0800 Subject: [PATCH 1/3] Bugfix: not finding parent_obj correctly --- addon.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/addon.py b/addon.py index 65648b1..e4ce959 100644 --- a/addon.py +++ b/addon.py @@ -1443,22 +1443,30 @@ class BlenderMCPServer: mesh_obj = imported_objects[0] print("Single mesh imported, no cleanup needed.") else: - parent_obj = imported_objects[0] - if parent_obj.type == 'EMPTY' and len(parent_obj.children) == 1: - potential_mesh = parent_obj.children[0] - if potential_mesh.type == 'MESH': - print("GLB structure confirmed: Empty node with one mesh child.") - - # Unparent the mesh from the empty node - potential_mesh.parent = None - - # Remove the empty node - bpy.data.objects.remove(parent_obj) - print("Removed empty node, keeping only the mesh.") - - mesh_obj = potential_mesh + if len(imported_objects) == 2: + empty_objs = [i for i in imported_objects if i.type == "EMPTY"] + if len(empty_objs) != 1: + print("Error: Expected an empty node with one mesh child or a single mesh object.") + return + parent_obj = empty_objs.pop() + if len(parent_obj.children) == 1: + potential_mesh = parent_obj.children[0] + if potential_mesh.type == 'MESH': + print("GLB structure confirmed: Empty node with one mesh child.") + + # Unparent the mesh from the empty node + potential_mesh.parent = None + + # Remove the empty node + bpy.data.objects.remove(parent_obj) + print("Removed empty node, keeping only the mesh.") + + mesh_obj = potential_mesh + else: + print("Error: Child is not a mesh object.") + return else: - print("Error: Child is not a mesh object.") + print("Error: Expected an empty node with one mesh child or a single mesh object.") return else: print("Error: Expected an empty node with one mesh child or a single mesh object.") From 8c56f1095e718ccebc24ebdfc84d0ad80d52cd53 Mon Sep 17 00:00:00 2001 From: ElgoogUdiab Date: Fri, 28 Mar 2025 14:59:04 +0800 Subject: [PATCH 2/3] Specify error: no glb download link when trying to import. --- addon.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addon.py b/addon.py index e4ce959..c101025 100644 --- a/addon.py +++ b/addon.py @@ -1533,7 +1533,9 @@ class BlenderMCPServer: return {"succeed": False, "error": str(e)} break - + else: + return {"succeed": False, "error": "Generation failed. Please submit a new generation task and try again."} + try: obj = self._clean_imported_glb( filepath=temp_file.name, From bdf2c17245857b10cde78c7c6096bd58b47ccf47 Mon Sep 17 00:00:00 2001 From: ElgoogUdiab Date: Fri, 28 Mar 2025 15:08:31 +0800 Subject: [PATCH 3/3] Correcting error message. --- addon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.py b/addon.py index c101025..f5e1798 100644 --- a/addon.py +++ b/addon.py @@ -1534,7 +1534,7 @@ class BlenderMCPServer: break else: - return {"succeed": False, "error": "Generation failed. Please submit a new generation task and try again."} + return {"succeed": False, "error": "Generation failed. Please first make sure that all jobs of the task are done and then try again later."} try: obj = self._clean_imported_glb(