From 9d997bd88bb7bde56acf760733b244ecc7e3f6dd Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 22 Jun 2022 18:04:13 +0300 Subject: [PATCH] Fix mesh exporting script: export armature if it is the selected object's parent --- tools/convert-mesh/bin/convert-mesh.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/convert-mesh/bin/convert-mesh.py b/tools/convert-mesh/bin/convert-mesh.py index 8a6f537e..1c1922eb 100644 --- a/tools/convert-mesh/bin/convert-mesh.py +++ b/tools/convert-mesh/bin/convert-mesh.py @@ -27,11 +27,10 @@ if len(mesh.uv_layers) > 0: texcoords = mesh.uv_layers.active.data print('Found texture coordinates') -# TODO: proper armature support armature = None bone_names = None -if 'armature' in bpy.data.objects: - armature = bpy.data.objects['armature'] +if type(obj.parent.data) is bpy.types.Armature: + armature = obj.parent print('Found armature with {} bones'.format(len(armature.data.bones))) bone_names = [b.name for b in armature.data.bones] @@ -175,8 +174,8 @@ if armature is not None: bones.append((p, tuple(b.head_local), tuple(map(tuple, b.matrix_local.to_3x3())))) poses = [] -if armature is not None: - for index, pose in enumerate(bpy.data.objects['armature'].pose_library.pose_markers): +if armature is not None and armature.pose_library is not None: + for index, pose in enumerate(armature.pose_library.pose_markers): print("Found pose", pose.name) # [rotation, scale, translation]