Vertex Group Dump script

This is a simple script that dumps the groups, and optionally the weights, of selected vertices on a mesh. Its likely to only run on 2.34 without changes though, so grab a test build if you aren’t working with a CVS build already or wait until 2.34 is released.

The script can be found http://www.visi.com/~zaz/vertexGroups.py for download or for posterity in the code block below.

Since this is so trivial, it is released without restriction, do with it as you wish.


#!BPY

"""
Name: 'Selected Vertex Group Dump'
Blender: 234
Group: 'Mesh'
Submenu: 'Vertex Groups Only' onlyGroups
Submenu: 'Vertex Groups With Weights' withWeights
Tip: 'Print Vertex Groups for Selected Vertices'
"""
import os
import Blender
from Blender import Object, NMesh

if __name__ == "__main__":
	editMode = Blender.Window.EditMode ()
	if editMode:
		Blender.Window.EditMode (0)
		Blender.Redraw ()
		Blender.Window.EditMode (1)

	obj = Object.GetSelected () [0]
	mesh = obj.data
	groupCount = 0
	count = 0

	onlyGroups = __script__['arg'] == 'onlyGroups'

	print "Selected Vertex Group Dump, processing mesh", mesh.name, "from object", obj.getName ()

	if onlyGroups:
		for grp in mesh.getVertGroupNames ():
			groupCount += 1
			for vidx in mesh.getVertsFromGroup (grp):
				vert = mesh.verts [vidx]
				if vert.sel:
					count += 1
					print "	", grp
					break
		print count, "groups involved out of", groupCount, "total groups."
	else:
		for vert in mesh.verts:
			if vert.sel:
				print "	Vertex:", vert.index, vert.co
				glist = mesh.getVertexInfluences(vert.index)
				if len (glist) > 0:
					for inf in glist:
						print "		", inf [0], inf [1]
				else:
					print "		**NO GROUPS**"