Ah-ha. I was appending a list to the list of connectedVerts.
I still need to test it a bit, but I think this gets me what I'm after. Thanks
guys for holding my hand through it.
btw, how are you guys nicely formatting your code? are there no <code> tags?
#=================================
import pymel.core as pm
from itertools import chain
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 = list( set( connectedVertGroups.get(vtxKey) ) )
connectedVertList = connectedVertList + [ vert for vert in
connectedVerts ]
vertList = list(vertGroups.get(vtxKey))
vertList.append( vtx )
connectedVertGroups[vtxKey] = connectedVertList
vertGroups[vtxKey] = vertList
#===============================
Kev
--
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/6cf4e066-9ca3-46fd-a734-7253d8876834%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.