Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
check max influence and select these vertex. for Maya
import maya.cmds as cmds
import maya.mel as mel
DEFAULT_MAXIMUM_INFULENCE = 5
##############################################################################
#1頂点に影響するジョイントの上限チェックする
##############################################################################
def check_maximum_influence(max=DEFAULT_MAXIMUM_INFULENCE):
res = []
cmds.select(clear=True)
skin_clusters = cmds.ls(type="skinCluster")
for cluster in skin_clusters:
for mesh in cmds.skinCluster(cluster, q=True, geometry=True):
res += check_mesh(max, cluster, mesh)
print("{0} 頂点のジョイントインフルエンスが上限 {1} を超えています".format(
len(res), max))
cmds.select(res)
def check_mesh(max, cluster, mesh):
vertices = cmds.polyListComponentConversion(mesh, toVertex=True)
vertices = cmds.filterExpand(vertices, selectionMask=31) # polygon vertex
res = []
for vert in vertices:
joints = cmds.skinPercent(
cluster, vert, query=True, ignoreBelow=0.000001, transform=None)
if len(joints) > max:
res.append(vert)
return res
check_maximum_influence()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment