I'm quite a noob in Python. I can write a simple script to assign a cluster to vertexes of the selected objects.
Like this:
import maya.cmds as cmds
activeSelection = cmds.ls(selection=True)
for i in activeSelection:
cmds.polyListComponentConversion( i, ff=True, tv=True, internal=True )
cmds.cluster( i, rel=True )
But it turned out I need to assign a cluster to vertexes of each individual polygon shell of the object. I've spent few hours searching and trying different scripts and trying to modify them but nothing seems to really work. Would you guys be so kind to give a hint?
Thank you,
Anton
If you don't want to separate and then re-combine your mesh (to keep clean history, or you're restricted from modifying the geo in any way except deformers for some reason...), you could use this to "separate" your shells out non-destructively
import maya.cmds as mc
shells = []
face_count = mc.polyEvaluate(geom, f=True)
faces = set(range(face_count))
for face in xrange(face_count):
if face in faces:
shell_indices = mc.polySelect(geom, q=True, extendToShell=face)
shell_faces = ['%s.f[%d]' %(geom, i) for i in shell_indices]
shells.append(mc.polyListComponentConversion(shell_faces, toVertex=True))
faces -= set(shell_indices)
elif not faces:
break
this will give you a list where each item is a list of cps for a shell. All that's left to do is to cluster each item of the shells list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With