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.

enter image description here

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.

  • 4
    $\begingroup$ why did you post your script as an image? Please post your code as text in a code block in the question. $\endgroup$
    – David
    Mar 24 '18 at 19:56

Use the active vertex group

import bpy

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.