# 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.

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

import bpy