Vertex -> Bone

Rigging yesterday, I was reminded of an idea I had a while back. A really helpful script would take selected vertices of a mesh in edit mode (or a vertex group), and create a single bone for each vertex.

Would someone be so kind as to help me out with this? (Or at least, where should a total noob start learning how to script something like this?)

Here you go:

import Blender 
from Blender import Armature, Object, Scene, Window 
     
# create new armature and link ot object / scene 
am = Armature.New('armature') 
 
ob = Object.New('Armature', 'armature') 
ob.link( am ) 
 
scn = Scene.GetCurrent() 
scn.link( ob ) 
 
am.makeEditable() #enter editmode 
 
# add bone for each vertex 
ob = Object.GetSelected()[0] # get the seletec object
me = ob.getData( mesh=1 ) 
for n in me.verts: 
    if n.sel: 
        pos = n.co.copy() 
        eb = Armature.Editbone() 
        eb.head = pos 
        pos.y += 1.0 
        eb.tail = pos 
     
        #add the bone 
        am.bones['Bone%i' % n.index] = eb 
         
am.update()  #save changes 
 
Window.RedrawAll()

That’s exactly what I needed – this is perfect! A million thanks, Loolarge!