pymel.core.animation.copyDeformerWeights

copyDeformerWeights(*args, **kwargs)

Command to copy or mirror the deformer 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
destinationDeformer / dd unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Specify the deformer used by the destination shape
destinationShape / ds unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Specify the destination deformed shape
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.
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.
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.
sourceDeformer / sd unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Specify the deformer whose weights should be mirrored. When queried, returns the deformers used by the source shapes.
sourceShape / ss unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Specify the source deformed 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. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.copyDeformerWeights

Example:

import pymel.core as pm

# Create plane and a cluster.
#
pm.file( f=True,new=True )
pm.polyPlane( ch=1, w=10, h=10, sx=5, sy=5, ax=(0,1,0) )
pm.cluster( n='testCluster', 'pPlane1' )
# Modify some weights on the -x side of the character
#
pm.select( ['pPlane1.vtx[0]', 'pPlane1.vtx[6]', 'pPlane1.vtx[12]', 'pPlane1.vtx[18]'])
pm.percent( 'testCluster', v='0.5' )
# 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.copyDeformerWeights( ss='pPlane1', ds='pPlane1', sd='testCluster', mirrorMode='YZ', mirrorInverse = True)
pm.select( ['pPlane1.vtx[5]', 'pPlane1.vtx[11]', 'pPlane1.vtx[17]', 'pPlane1.vtx[23]'])
pm.percent( 'testCluster', q=True, v=True )