+ if self.export_groups:
+ mesh.sort_vertex_groups(self.max_groups)
+
+ # Create a mapping from vertex group indices to bone indices
+ group_index_map = dict((i, i) for i in range(len(objs[0].vertex_groups)))
+ if objs[0].parent and objs[0].parent.type=="ARMATURE":
+ armature = objs[0].parent.data
+ bone_indices = dict((armature.bones[i].name, i) for i in range(len(armature.bones)))
+ for g in objs[0].vertex_groups:
+ if g.name in bone_indices:
+ group_index_map[g.index] = bone_indices[g.name]
+