# Imported OBJ Groups to Vertex Groups

I have an OBJ file for a character, which I have divided into groups (left hand, right leg, etc).

I have imported it with separate objects for each group. I can get rid of the seams and all the groups with the join command (Ctrl + J), but then there are no vertex groups. Which I need for rigging. (I know there are other ways I can make vertex groups, just pretend I need them based on this OBJ file's groups.)

What is the fastest, most efficient way to convert all these separate objects into one object with vertex groups named with the separate object names? is there a magic script/button for that?

You can write a script to create the groups with all the vertecies in one group for each mesh and then just join it.

I just quickly threw this together. I don't usually write much python, so don't confuse this with good code (I'm sure some list comprehensions could clean this up nicely).

import bpy;

selected = bpy.context.selected_objects
print(selected)
selected_meshes = []

# only use meshes of the selected objects
for obj in selected:
if obj.type == 'MESH':
selected_meshes.append(obj)

# for each mesh make a vertex group with all vertices in it
for obj in selected_meshes:
vg = obj.vertex_groups.new(obj.name)
verts = []
for vt in obj.data.vertices:
verts.append(vt.index)