Skip to content

Instantly share code, notes, and snippets.

@yamahigashi
Created June 30, 2015 09:17
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yamahigashi/635f16a5948ec0389139 to your computer and use it in GitHub Desktop.
Save yamahigashi/635f16a5948ec0389139 to your computer and use it in GitHub Desktop.
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