pymel.core.animation.copySkinWeights

copySkinWeights(*args, **kwargs)

Command to copy or mirror the skinCluster weights accross one of the three major axes. The command can be used to mirror weights either from one surface to another or within the same surface. In query mode, return type is based on queried flag.

Flags:
Long name (short name) Argument Types Properties
destinationSkin (ds) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify the destination skin shape
influenceAssociation (ia) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

The influenceAssociation flag controls how the influences on the source and target skins are matched up. The flag can be included multiple times to specify multiple association schemes that will be invoked one after the other until all influences have been matched up. Supported values are “closestJoint”, “closestBone”, “label”, “name”, “oneToOne”. The default is closestJoint.

mirrorInverse (mi) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Values are mirrored from the positive side to the negative. If this flag is used then the direction is inverted.
mirrorMode (mm) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The mirrorMode flag defines the plane of mirroring (XY, YZ, or XZ) when the mirror flag is used. The default plane is XY.
noBlendWeight (nbw) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

When the no blend flag is used, the blend weights on the skin cluster will not be copied across to the destination.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

noMirror (nm) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
When the no mirror flag is used, the weights are copied instead of mirrored.
normalize (nr) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Normalize the skin weights.
sampleSpace (spa) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Selects which space the attribute transfer is performed in. 0 is world space, 1 is model space. The default is world space.
smooth (sm) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
When the smooth flag is used, the weights are smoothly interpolated between the closest vertices, instead of assigned from the single closest.
sourceSkin (ss) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify the source skin shape
surfaceAssociation (sa) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

The surfaceAssociation flag controls how the weights are transferred between the surfaces: “closestPoint”, “rayCast”, or “closestComponent”. The default is closestComponent.

uvSpace (uv) unicode, unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The uvSpace flag indicates that the weight transfer should occur in UV space, based on the source and destination UV sets specified.

Derived from mel command maya.cmds.copySkinWeights

Example:

import pymel.core as pm

import maya.cmds as cmds

# Create plane and a skeleton. Bind the skin.
#
pm.file( f=True,new=True )
pm.polyPlane( ch=1, w=10, h=10, sx=5, sy=5, ax=(0,1,0) )
pm.select( d=True )
pm.joint( p=(0, 0, -6) )
pm.joint( p=(0, 0, -4) )
pm.joint( 'joint1', e=True, zso=True, oj='xyz')
pm.joint( p=(2, 0, -4) )
pm.joint( 'joint2', e=True, zso=True, oj='xyz')
pm.joint( p=(5, 0, -3) )
pm.joint( 'joint3', e=True, zso=True, oj='xyz')
pm.select( 'joint2', r=True )
pm.joint( p=(-2, 0, -4) )
pm.joint( 'joint4', e=True, zso=True, oj='xyz')
pm.joint( p=(-5, 0, -3) )
pm.joint( 'joint5', e=True, zso=True, oj='xyz')
pm.select( 'joint2', r=True )
pm.joint( p=(0, 0, 3) )
pm.joint( 'joint6', e=True, zso=True, oj='xyz')
pm.joint( p=(5, 0, 5) )
pm.joint( 'joint7', e=True, zso=True, oj='xyz')
pm.select( 'joint7', r=True )
pm.joint( p=(-5, 0, 5) )
pm.joint( 'joint8', e=True, zso=True, oj='xyz')
pm.select( 'pPlane1', 'joint1', r=True )
maya.mel.eval('createSkinCluster "-mi 5 -dr 4"' )
# Modify some weights on the -x side of the character
#
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[30]', tv=('joint2',0.200000) )
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[31]', tv=('joint2',0.200000) )
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[24]', tv=('joint5',0.550000) )
pm.skinPercent( 'skinCluster1', 'pPlane1.vtx[25]', tv=('joint5',0.550000) )
# Mirror the skin weights to the other side of the character
# Mirror inverse is chosen since we want to go from -x to +x, not +x to -x.
#
pm.copySkinWeights( ss='skinCluster1', ds='skinCluster1', mirrorMode='YZ', mirrorInverse=True )
# Now create a second plane and bind it as skin
#
pm.polyPlane( ch=1, w=10, h=10, sx=5, sy=5, ax=(0,1,0) )
pm.select( 'pPlane2', r='joint1' )
maya.mel.eval('createSkinCluster "-mi 5 -dr 4"' )
# Copy the skin weights from the first plane onto the new plane.
# The -noMirror flag is used since we want to copy directly, not mirror.
#
pm.copySkinWeights( ss='skinCluster1', ds='skinCluster2', noMirror=True )

Previous topic

pymel.core.animation.copyKey

Next topic

pymel.core.animation.currentTime

Core

Core Modules

Other Modules

This Page