I am currently porting some code from the 2.49 API to the 2.6 API and looking for a nice way to replace this function call
vert_list["bone"] = b_obj.data.getVertsFromGroup("bone", 1)
This function returned a list of vertex tuples (index, weight).
Edit: A nice side effect of this function was that it also threw an AttributeError
if the had no associated vertices group. Empty VertGroups are not allowed by our exporter.
I coded up a working sample for what I think I need based on the 2.49 API to show how I intend to access these values. This has been simplified with hard coded values.
import bpy
b_obj = bpy.data.objects['Cube']
b_verts = b_obj.data.vertices
b_arm = bpy.data.objects['Armature']
b_vert_group = b_obj.vertex_groups['Bone']
b_group_index = b_vert_group.index
b_list = []
for b_vert in b_verts:
for g in b_vert.groups:
if g.group == b_group_index:
b_list.append((b_vert.index, g.weight))
What I am wondering is if anyone has an alternative way of accessing these values or perhaps someone would give a more pythonic version.
Most of the samples I have encountered relating to vertex groups are geared towards assignment rather than access. Even if I don't get an answer it might help someone else down the road.
append
(last line). $\endgroup$