Getting vertex groups from bones


I’m working on an exporter addon for blender 2.5. It’s working good so far, but I have one small problem.

When exporting a mesh’s armature, I can’t figure out how to get the vertex groups that are influenced by a bone (or vice versa). I know each bone has a corresponding vertex group associated with it, and usually these two will have the same name. At first I just matched up bone names with vertex group names, but it has proven problematic, so I’m wondering if there’s a way to just get the corresponding vertex group ID.

Any suggestions would be much appreciated.