pymel.core.general.bakePartialHistory

bakePartialHistory(*args, **kwargs)

This command is used to bake sections of the construction history of a shape node when possible. A typical usage would be on a shape that has both modelling operations and deformers in its history. Using this command with the -prePostDeformers flag will bake the modeling portions of the graph, so that only the deformers remain. Note that not all modeling operations can be baked such that they create exactly the same effect after baking. For example, imagine the history contains a skinning operation followed by a smooth. Before baking, the smooth operation is performed each time the skin deforms, so it will smooth differently depending on the output of the skin. When the smooth operation is baked into the skinning, the skin will be reweighted based on the smooth points to attempt to approximate the original behavior. However, the skin node does not perform the smooth operation, it merely performs skinning with the newly calculated weights and the result will not be identical to before the bake. In general, modeling operations that occur before deformers can be baked precisely. Those which occur after can only be approximated. The -pre and -post flags allow you to control whether only the operations before or after the deformers are baked. When the command is used on an object with no deformers, the entire history will be deleted.

Flags:

Long Name / Short Name Argument Types Properties
allShapes / all bool ../../../_images/create.gif ../../../_images/query.gif
  Specifies that the bake operation should be performed on all shapes in the entire scene. By default, only selected objects are baked. If this option is specified and there are no shapes in the scene, then this command will do nothing and end successfully.
postSmooth / nps bool ../../../_images/create.gif ../../../_images/query.gif
  Specifies whether or not a smoothing operation should be done on skin vertices. This smoothing is only done on vertices that are found to deviate largely from other vertex values. The default is false.
preCache / pc bool ../../../_images/create.gif ../../../_images/query.gif
  Specifies baking of any history operations that occur before the caching operation, including deformers. In query mode, returns a list of the nodes that will be baked.
preDeformers / pre bool ../../../_images/create.gif ../../../_images/query.gif
  Specifies baking of any modeling operations in the history that occur before the deformers. In query mode, returns a list of the nodes that will be baked.
prePostDeformers / ppt bool ../../../_images/create.gif ../../../_images/query.gif
  Specifies baking of all modeling operations in the history whether they are before or after the deformers in the history. If neither the -prePostDeformers nor the -preDeformers flag is specified, prePostDeformers will be used as the default. In query mode, returns a list of the nodes that will be baked. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.bakePartialHistory

Example:

import pymel.core as pm

# create a cylinder with history to use as an example
#
cyl = pm.polyCylinder()
pm.polySmooth()
# Result: [nt.PolySmoothFace(u'polySmoothFace1')] #
pm.cluster()
# Result: [nt.Cluster(u'cluster1'), nt.Transform(u'cluster1Handle')] #
pm.select( cyl[0],r=True )
pm.polyTriangulate()
# Result: [nt.PolyTriangulate(u'polyTriangulate1')] #
# query what will be baked
#
pm.bakePartialHistory( cyl[0],query=True,prePostDeformers=True )
# Result: [u'polyTriangulate1', u'pCylinderShape1Orig', u'polySmoothFace1', u'polyCylinder1'] #
# perform the bake, baking history from before and after the
# deformer
#
pm.bakePartialHistory( cyl[0],prePostDeformers=True )
# Result: [u'pCylinderShape1'] #
# Bake the history before the geometry cache on the cylinder.
# To actually demo, add a geometry cache before executing the command
# below.
#
pm.select( cyl[0],r=True )
pm.bakePartialHistory( cyl[0],preCache=True )
# Result: [u'pCylinderShape1'] #