Renaming an obj based on a Vertex Group script I have a model with parts named obj0, obj1 etc which I am creating vertex groups with the same name for. I'm joing them together to edo and then After editing the model I split by vertices. I'm trying to rename all the original parts their name based on their vertex group name now using a script to save time. The following is what I have so far.



I have this which works when there's just one vertex group in the obj, but after splitting by vertex it keeps the remaining ones in. How would I edit this code so that the obj is renamed from the VertexGroups.active_index selected instead of the at the top of the list?

Thank you.
Use the active vertex group 

import bpy

for ob in context.selected_objects:
    avg = ob.vertex_groups.active
    if avg:
        ob.name = avg.name