pymel.core.animation.skinPercent

skinPercent(*args, **kwargs)

This command edits and queries the weight values on members of a skinCluster node, given as the first argument. If no object components are explicitly mentioned in the command line, the current selection list is used. Note that setting multiple weights in a single invocation of this command is far more efficient than calling it once per weighted vertex. In query mode, return type is based on queried flag.

Flags:
Long name (short name) Argument Types Properties
ignoreBelow (ib) float ../../../_images/query.gif
 

Limits the output of the -value and -transform queries to the entries whose weight values are over the specified limit. This flag has to be used before the -query flag.

normalize (nrm) bool ../../../_images/create.gif
 

If set, the weights not assigned by the -transformValue flag are normalized so that the sum of the all weights for the selected object component add up to 1. The default is on. NOTE: The skinCluster has a normalizeWeights attribute which when set to OFF overrides this attribute! If the skinCluster.normalizeWeights attribute is OFF, you must set it to Interactive in order to normalize weights using the skinPercent command.

pruneWeights (prw) float ../../../_images/create.gif
 

Sets to zero any weight smaller than the given value for all the selected components. To use this command to set all the weights to zero, you must turn the -normalize flag “off” or the skinCluster node will normalize the weights to sum to one after pruning them. Weights for influences with a true value on their “Hold Weights” attribute will not be pruned.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

relative (r) bool ../../../_images/create.gif
 

Used with -transformValue to specify a relative setting of values. If -relative is true, the value passed to -tv is added to the previous value. Otherwise, it replaces the previous value.

resetToDefault (rtd) bool ../../../_images/create.gif
 
Sets the weights of the selected components to their default values, overwriting any custom weights.
transform (t) unicode ../../../_images/query.gif
 

If used after the -query flag (without an argument) the command returns an array of strings corresponding to the names of the transforms influencing the selected object components. If used before the -query flag (with a transform name), the command returns the weight of the selected object component corresponding to the given transform. The command will return an average weight if several components have been selected. In query mode, this flag can accept a value.

transformMoveWeights (tmw) unicode ../../../_images/create.gif
 

This flag is used to transfer weights from a source influence to one or more target influences. It acts on the selected vertices. The flag must be used at least twice to generate a valid command. The first flag usage indicates the source influence from which the weights will be copied. Subsequent flag usages indicate the target influences.

transformValue (tv) unicode, float ../../../_images/create.gif
 

Accepts a pair consisting of a transform name and a value and assigns that value as the weight of the selected object components corresponding to the given transform.

value (v) bool ../../../_images/query.gif
 
Returns an array of doubles corresponding to the joint weights for the selected object component.
zeroRemainingInfluences (zri) bool ../../../_images/create.gif
 
If set, the weights not assigned by the -transformValue flag are set to 0. The default is off.

Derived from mel command maya.cmds.skinPercent

Example:

import pymel.core as pm

# Create a joint chain and a polygonal plane and bind them as skin
pm.select(d=True)
pm.joint(p=(-3.0, 0.0,-12.0))
# Result: nt.Joint(u'joint1') #
pm.joint(p=(-3.0, 0.0, -5.0))
# Result: nt.Joint(u'joint2') #
pm.joint(p=(1.0, 0.0, 5.5))
# Result: nt.Joint(u'joint3') #
pm.joint(p=(6.0, 0.0, 10.0))
# Result: nt.Joint(u'joint4') #
pm.polyPlane(w=20.0,h=20.0,sx=25,sy=25)
# Result: [nt.Transform(u'pPlane1'), nt.PolyPlane(u'polyPlane1')] #
pm.skinCluster( 'joint1', 'pPlane1' )
# Result: nt.SkinCluster(u'skinCluster1') #

# For vtx[100], set the weight wrt joint1 to 0.2, the weight
# wrt joint3 to 0.8 and adjust the remaining weights to keep
# the overall weight normalized (i.e. set all other joints to zero,
# since the weights we are setting sum to 1.0)
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', transformValue=[('joint1', 0.2), ('joint3', 0.8)])

# Get the weight values corresponding to all of the influences
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', query=True, value=True )
# Result: [0.2, 0.0, 0.8, 0.0] #

# Get the weight values that are above 0.5
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', ignoreBelow=0.5, query=True, value=True )
# Result: [0.8] #

# Get the weight of vtx[100] corresponding to joint1
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', transform='joint1', query=True )
# Result: 0.2 #

# Normalize the existing weights for vtx[100]
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', normalize=True )

# Reset the weights for vtx[100] to their default values
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', resetToDefault=True )

# Zero all the weights that are below 0.1
#
pm.skinPercent( 'skinCluster1', 'pPlane1', pruneWeights=0.1 )

# Zero all the weights
#
pm.skinPercent( 'skinCluster1', 'pPlane1', pruneWeights=100, normalize=False )

# Assign weights to a large number of vertices,
# several at a time to reduce the number of calls
# to the skinPercent command.
#
for i in range(0,675,10):
   pm.select('pPlane1.vtx[%i]' % i,'pPlane1.vtx[%i]' % (i+1), 'pPlane1.vtx[%i]' % (i+2), 'pPlane1.vtx[%i]' % (i+3), 'pPlane1.vtx[%i]' % (i+4), 'pPlane1.vtx[%i]' % (i+5), 'pPlane1.vtx[%i]' % (i+6), 'pPlane1.vtx[%i]' % (i+7), 'pPlane1.vtx[%i]' % (i+8), 'pPlane1.vtx[%i]' % (i+9))
   pm.skinPercent( 'skinCluster1',transformValue=[('joint1', 0.5),('joint2', 0.5)] )

Previous topic

pymel.core.animation.skinCluster

Next topic

pymel.core.animation.snapKey

Core

Core Modules

Other Modules

This Page