-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoftCluster
42 lines (31 loc) · 1.2 KB
/
SoftCluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#souce:gitHub#
#create soft selection &run the script
import maya.cmds as mc
import maya.OpenMaya as om
def softSelection():
selection = om.MSelectionList()
softSelection = om.MRichSelection()
om.MGlobal.getRichSelection(softSelection)
softSelection.getSelection(selection)
dagPath = om.MDagPath()
component = om.MObject()
iter = om.MItSelectionList( selection,om.MFn.kMeshVertComponent )
elements = []
while not iter.isDone():
iter.getDagPath( dagPath, component )
dagPath.pop()
node = dagPath.fullPathName()
fnComp = om.MFnSingleIndexedComponent(component)
for i in range(fnComp.elementCount()):
elements.append([node, fnComp.element(i), fnComp.weight(i).influence()] )
iter.next()
return elements
def createSoftCluster():
softElementData = softSelection()
selection = ["%s.vtx[%d]" % (el[0], el[1])for el in softElementData ]
mc.select(selection, r=True)
cluster = mc.cluster(relative=True)
for i in range(len(softElementData)):
mc.percent(cluster[0], selection[i], v=softElementData[i][2])
mc.select(cluster[1], r=True)
createSoftCluster()