okay, I think I get it, get the value of the key, append the vtx to the list,
then set that list as the value for the key. And from the looks of it, it seems
as though everything should work now. So why doesn't it work :(
#==============================
import pymel.core as pm
sel = pm.ls(sl=1, fl=True)
connectedVertGroups = {}
vertGroups = {}
for i, vtx in enumerate(sel):
vtxKey = next((key for key, vtx_list in connectedVertGroups.iteritems() if
vtx in vtx_list), None)
connectedVerts = [ vert for vert in vtx.connectedVertices() ]
connectedVerts.append(vtx)
if vtxKey is None:
connectedVertGroups["group_{0}".format(i)] = connectedVerts
vertGroups["group_{0}".format(i)] = vtx
else:
connectedVertList = connectedVertGroups.get(vtxKey)
connectedVertList.append( connectedVerts )
vertList = list(vertGroups.get(vtxKey))
vertList.append( vtx )
connectedVertGroups[vtxKey] = connectedVertList
vertGroups[vtxKey] = vertList
#=============================
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/ef5570bc-10e4-43e6-a1b5-fd0f2c26696c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.