I'm trying to modify an object's vertex groups from a python script. I've come up with the following code which throws no errors, but doesn't change the values in the vertex groups:
class scaleWeight(bpy.types.Operator):
bl_idname = "object.scaleweight"
bl_label = "scale vertex groups"
def execute(self, context):
ob = context.active_object
try:
assert ob.vertex_groups
except:
return
for v in ob.data.vertices:
#print(v.index)
for grp in ob.vertex_groups:
weight = grp.weight(v.index)
#print('weight=', weight)
try:
grp.add(v.index, weight * 0.5, 'REPLACE')
except:
#print('err')
continue
ob.data.update()
return {"FINISHED"}
Can anyone tell me where I've gone wrong here?
grp.add()
takes a list for the first param, not a single int. $\endgroup$