# How are the Bones assigned to the Vertex_Groups in the API?

I´m working on an export script for Blender and I´m currently stuck at exporting bone weights.

Here is what i have so far(excuse me if my Python is not that clean, the syntax is pretty new to me):

v0.Inf = [0.0,0.0,0.0,0.0]
for i,g in enumerate(face.vertices[0].groups):
if not g.weight = 0.0:
v0.Inf[i] = g.group + g.weight


As far as I understand this it should fill the 4 elements of my array with the sum of the group index and the weight of that particular vertex. (Note: It´s guaranteed that there are max. 4 groups)

But i´m running into some problems here: I have a test-file which has 3 vertex groups but 2 bones. How do i figure out which vertex group is assigned to which bone? There has to be some kind of connection. I can´t use the group name because the group can have a diffrent name than the bone, even if that´s a rare case.

Bones are matched to vertex groups based on names, that is the connection, they are not linked in another way.

for modifier in object.modifiers:
if modifier.type == 'ARMATURE' and modifier.object:
armature = modifier.object.data

for bone in armature.bones:
if bone.use_deform and bone.name in object.vertex_groups:
print("'%s' used for armature deformation" % bone.name)