pymel.core.animation.blendShape¶
- blendShape(*args, **kwargs)¶
This command creates a blendShape deformer, which blends in specified amounts of each target shape to the initial base shape. Each base shape is deformed by its own set of target shapes. Every target shape has an index that associates it with one of the shape weight values.In the create mode the first item on the selection list is treated as the base and the remaining inputs as targets. If the first item on the list has multiple shapes grouped beneath it, the targets must have an identical shape hierarchy. Additional base shapes can be added in edit mode using the deformers -g flag.
Flags:
Long Name / Short Name Argument Types Properties after / af bool If the default behavior for insertion/appending into/onto the existing chain is not the desired behavior then this flag can be used to force the command to place the deformer node after the selected node in the chain even if a new geometry shape has to be created in order to do so. Works in create mode (and edit mode if the deformer has no geometry added yet). afterReference / ar bool The -afterReference flag is used to specify deformer ordering in a hybrid way that choses between -before and -after automatically. If the geometry being deformed is referenced then the -after mode is used when adding the new deformer, otherwise the -before mode is used. The net effect when using -afterReference to build deformer chains is that internal shape nodes in the deformer chain will only appear at reference file boundaries, leading to lightweight deformer networks that may be more amicable to reference swapping. automatic / at bool The -automatic flag is used to specify deformer ordering in a way that choses between -frontOfChain and -before automatically. If the geometry being deformed is only affected by invertible deformers, the -frontOfChain mode is used, otherwise the -before mode is used. before / bf bool If the default behavior for insertion/appending into/onto the existing chain is not the desired behavior then this flag can be used to force the command to place the deformer node before the selected node in the chain even if a new geometry shape has to be created in order to do so. Works in create mode (and edit mode if the deformer has no geometry added yet). copyDelta / cd int, int, int Set the base, source, and destination delta index values. copyInBetweenDelta / cid int, int, int, int Set the base, target, source, and destination delta index values. deformerTools / dt bool Returns the name of the deformer tool objects (if any) as string string ... envelope / en float Set the envelope value for the deformer, controlling how much of the total deformation gets applied. Default is 1.0. exclusive / ex unicode Puts the deformation set in a deform partition. export / ep unicode Export the shapes to the named file path. exportTarget / et int, int Specify the base and target index pairs for the export. flipTarget / ft int, int Flip the list of base and target pairs. frontOfChain / foc bool This command is used to specify that the new deformer node should be placed ahead (upstream) of existing deformer and skin nodes in the shape’s history (but not ahead of existing tweak nodes). The input to the deformer will be the upstream shape rather than the visible downstream shape, so the behavior of this flag is the most intuitive if the downstream deformers are in their reset (hasNoEffect) position when the new deformer is added. Works in create mode (and edit mode if the deformer has no geometry added yet). geometry / g unicode The specified object will be added to the list of objects being deformed by this deformer object, unless the -rm flag is also specified. When queried, this flag returns string string string ... geometryIndices / gi bool Complements the -geometry flag in query mode. Returns the multi index of each geometry. ignoreSelected / ignoreSelected bool Tells the command to not deform objects on the current selection list inBetween / ib bool Indicate that the specified target should serve as an inbetween. An inbetween target is one that serves as an intermediate target between the base shape and another target. inBetweenIndex / ibi int Only used with the -rtd/-resetTargetDelta flag to remove delta values for points in the inbetween target geometry defined by this index. inBetweenType / ibt unicode Specify if the in-between target to be created is relative to the hero target or if it is absolute. If it is relative to hero targets, the in-between target will get any changes made to the hero target. Valid values are relativeand absolute. This flag should always be used with the -ib/-inBetween and -t/-target flags. includeHiddenSelections / ihs bool Apply the deformer to any visible and hidden objects in the selection list. Default is false. ip / ip unicode Import the shapes from the named file path. mergeSource / mgs int List of source indexes for a merge. mergeTarget / mgt int Target index of a merge mirrorDirection / md int Mirror direction; 0 = negative, 1 = positive mirrorTarget / mt int, int Mirror the list of base and target pairs. name / n unicode Used to specify the name of the node being created. normalizationGroups / ng bool Returns a list of the used normalization group IDs. origin / o unicode blendShape will be performed with respect to the world by default. Valid values are worldand local. The local flag will cause the blend shape to be performed with respect to the shape’s local origin. parallel / par bool Inserts the new deformer in a parallel chain to any existing deformers in the history of the object. A blendShape is inserted to blend the parallel results together. Works in create mode (and edit mode if the deformer has no geometry added yet). prune / pr bool Removes any points not being deformed by the deformer in its current configuration from the deformer set. remove / rm bool Specifies that objects listed after the -g flag should be removed from this deformer. resetTargetDelta / rtd int, int Remove all delta values for points in the target geometry, including all sequential targets defined by target index. Parameter list: uint: the base object indexuint: the target index split / sp bool Branches off a new chain in the dependency graph instead of inserting/appending the deformer into/onto an existing chain. Works in create mode (and edit mode if the deformer has no geometry added yet). symmetryAxis / sa unicode Axis for symmetry. Valid values are X, Y, and Z. symmetryEdge / se unicode One or two symmetry edge names, separated by a .. See the blendShape node’s symmetryEdge attribute for legal values. symmetrySpace / ss int Space for symmetry. 0 = Topological, 1 = Object, 2 = UV tangentSpace / ts bool Indicate that the delta of the specified target should be relative to the tangent space of the surface. target / t unicode, int, unicode, float Set target object as the index target shape for the base shape base object. The full influence of target shape takes effect when its shape weight is targetValue. Parameter list: string: the base objectint: indexstring: the target objectdouble: target value topologyCheck / tc bool Set the state of checking for a topology match between the shapes being blended. Default is on. transform / tr unicode Set transform for target, then the deltas will become relative to a post transform. Typically the best workflow for this option is to choose a joint that is related to the fix you have introduced. This flag should be used only if the Deformation orderof blendShape node is Before. weight / w int, float Set the weight value (second parameter) at index (first parameter). weightCount / wc int Set the number of shape weight values. Flag can have multiple arguments, passed either as a tuple or a list. Derived from mel command maya.cmds.blendShape
Example:
import pymel.core as pm # # Perform a blendShape using the currently-selected objects. # The lead (last-selected) object will be the base shape, and each # of the others become targets. # pm.blendShape() # # Create a blendShape that starts with curve3 as the base, and blends # in curve1 and curve2 as targets. pm.blendShape( 'curve1', 'curve2', 'curve3' ) # # Apply 80% of the total blendShape deformation, by setting # the envelope parameter to 0.8 pm.blendShape( 'blendShape1', edit=True, en=0.8 ) # # Set the weights for the first two target shapes to 0.6 # and 0.1 respecxtively pm.blendShape( 'blendShape1', edit=True, w=[(0, 0.6), (1, 0.1)] ) # # Add a third target (target3) to the blendShape on curve3 pm.blendShape( 'blendShape1', edit=True, t=('curve3', 1, 'target3', 1.0) ) # # Add an inbetween (smirk) on target3 for base shape curve3 # The inbetween will take effect at a weight of 0.2 pm.blendShape( 'blendShape2', edit=True, ib=True, t=('curve3', 2, 'smirk', 0.2) )