Fix mesh exporting script: export armature if it is the selected object's parent

This commit is contained in:
Nikita Lisitsa 2022-06-22 18:04:13 +03:00
parent a439d33b0f
commit 9d997bd88b

View file

@ -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]