Merge pull request #88 from DeemosTech/rodin-intergration
Bugfix: not finding parent_obj correctly when importing glb from rodin generated results
This commit is contained in:
commit
ce7b80fb00
42
addon.py
42
addon.py
@ -1190,22 +1190,30 @@ class BlenderMCPServer:
|
|||||||
mesh_obj = imported_objects[0]
|
mesh_obj = imported_objects[0]
|
||||||
print("Single mesh imported, no cleanup needed.")
|
print("Single mesh imported, no cleanup needed.")
|
||||||
else:
|
else:
|
||||||
parent_obj = imported_objects[0]
|
if len(imported_objects) == 2:
|
||||||
if parent_obj.type == 'EMPTY' and len(parent_obj.children) == 1:
|
empty_objs = [i for i in imported_objects if i.type == "EMPTY"]
|
||||||
potential_mesh = parent_obj.children[0]
|
if len(empty_objs) != 1:
|
||||||
if potential_mesh.type == 'MESH':
|
print("Error: Expected an empty node with one mesh child or a single mesh object.")
|
||||||
print("GLB structure confirmed: Empty node with one mesh child.")
|
return
|
||||||
|
parent_obj = empty_objs.pop()
|
||||||
# Unparent the mesh from the empty node
|
if len(parent_obj.children) == 1:
|
||||||
potential_mesh.parent = None
|
potential_mesh = parent_obj.children[0]
|
||||||
|
if potential_mesh.type == 'MESH':
|
||||||
# Remove the empty node
|
print("GLB structure confirmed: Empty node with one mesh child.")
|
||||||
bpy.data.objects.remove(parent_obj)
|
|
||||||
print("Removed empty node, keeping only the mesh.")
|
# Unparent the mesh from the empty node
|
||||||
|
potential_mesh.parent = None
|
||||||
mesh_obj = potential_mesh
|
|
||||||
|
# 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:
|
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
|
return
|
||||||
else:
|
else:
|
||||||
print("Error: Expected an empty node with one mesh child or a single mesh object.")
|
print("Error: Expected an empty node with one mesh child or a single mesh object.")
|
||||||
@ -1272,7 +1280,9 @@ class BlenderMCPServer:
|
|||||||
return {"succeed": False, "error": str(e)}
|
return {"succeed": False, "error": str(e)}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
return {"succeed": False, "error": "Generation failed. Please first make sure that all jobs of the task are done and then try again later."}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj = self._clean_imported_glb(
|
obj = self._clean_imported_glb(
|
||||||
filepath=temp_file.name,
|
filepath=temp_file.name,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user