Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Maya create soft cluster
import maya.cmds as mc
import maya.OpenMaya as om
def softSelection():
selection = om.MSelectionList()
softSelection = om.MRichSelection()
dagPath = om.MDagPath()
component = om.MObject()
iter = om.MItSelectionList( selection,om.MFn.kMeshVertComponent )
elements = []
while not iter.isDone():
iter.getDagPath( dagPath, component )
node = dagPath.fullPathName()
fnComp = om.MFnSingleIndexedComponent(component)
for i in range(fnComp.elementCount()):
elements.append([node, fnComp.element(i), fnComp.weight(i).influence()] )
return elements
def createSoftCluster():
softElementData = softSelection()
selection = ["%s.vtx[%d]" % (el[0], el[1])for el in softElementData ], r=True)
cluster = mc.cluster(relative=True)
for i in range(len(softElementData)):
mc.percent(cluster[0], selection[i], v=softElementData[i][2])[1], r=True)

This comment has been minimized.

Copy link
Owner Author

@jhoolmans jhoolmans commented Feb 24, 2014

Stacking clusters seems to be way more useful, compared to softMod, since the components are bound from the beginning. SoftMods deform based on radius from falloffCenter, making it unreliable whether components are in range when stacked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.