import bpy import random def main(context,group): for v in bpy.context.active_object.data.vertices: for g in v.groups: if g.group == group.index: g.weight = random.random() class RandomVertexWeight(bpy.types.Operator): '''Tooltip''' bl_idname = "object.random_vertex_weight" bl_label = "Randomize Vertex Weights" bl_options = {'REGISTER', 'UNDO'} GroupName = bpy.props.StringProperty( name="Group Name", description="name of group to randomize", default="Group", ) @classmethod def poll(cls, context): return context.active_object is not None def execute(self, context): group = context.active_object.vertex_groups[self.GroupName] main(context,group) return {'FINISHED'} def menu_func(self, context): self.layout.operator(RandomVertexWeight.bl_idname) def register(): bpy.utils.register_class(RandomVertexWeight) def unregister(): bpy.utils.unregister_class(RandomVertexWeight) if __name__ == "__main__": register()