Creates one or more cache files on disk to store attribute data for a span of frames. The caches can be created for either points on a geometry (using the pts/points flag) or for vectorArray output data (using the oa/outAttr flag). When the ia/inAttr flag is used, connects a cacheFile node that associates the data file on disk with the attribute. Frames can be replaced/appended to an existing cache with the rcf/replaceCachedFrame and apf/appendFrame flag. Replaced frames are never deleted. They are stored in the same directory as the original cache files with the name provided by the f/fileName flag. If no file name is provided, the cacheFile name is prefixed with “backup” followed by a unique number. Single file caches are backed up in their entirety. To revert to an older version, simply attach to this cache. One file per frame caches only backup the description file and the frames that were replaced. To recover these types of caches, the user must rename these files to the original name.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
appendFrame (apf) | bool | ||
Appends data to the cache for the times specified by the startTime and endTime flags. If no time is provided, appends the current time. Must be used in conjunction with the pts/points or cnd/cacheableNode flag. Any overwritten frames will not be deleted, but renamed as specified by the f/fileName flag. |
|||
attachFile (af) | bool | ||
Used to indicate that rather than creating a cache file, that an existing cache file on disk should be attached to an attribute in the scene. The inAttr flag is used to specify the attribute. |
|||
cacheFileNode (cfn) | unicode | ||
|
|||
cacheFormat (cf) | unicode | ||
Cache file format, default is Maya’s .mcx format, but others available via pluginFlag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
|||
cacheInfo (ci) | unicode | ||
In create mode, used to specify a mel script returning a string array. When creating the cache, this mel script will be executed and the returned strings will be written to the .xml description file of the cache. In query mode, returns descriptive info stored in the cacheFile such as the user name, Maya scene name and maya version number. |
|||
cacheableAttrs (cat) | unicode | ||
|
|||
cacheableNode (cnd) | unicode | ||
Specifies the name of a cacheable node whose contents will be cached. A cacheable node is a node that is specially designed to work with the caching mechanism. An example of a cacheable node is a nCloth node. |
|||
channelIndex (chi) | bool | ||
|
|||
channelName (cnm) | unicode | ||
When attachFile is used, used to indicate the channel in the file that should be attached to inAttr. If not specified, the first channel in the file is used. In query mode, allows user to query the channels associated with a description file. |
|||
convertPc2 (pc2) | bool | ||
|
|||
createCacheNode (ccn) | bool | ||
|
|||
creationChannelName (cch) | unicode | ||
When creating a new cache, this multi-use flag specifies the channels to be cached. The names come from the cacheable channel names defined by the object being cached. If this flag is not used when creating a cache, then all cacheable channels are cached. |
|||
dataSize (dsz) | bool | ||
This is a query-only flag that returns the size of the data being cached per frame. This flag is to be used in conjunction with the cacheableNode, points, and outAttr flags. |
|||
deleteCachedFrame (dcf) | bool | ||
Deletes cached data for the times specified by the startTime/endTime flags. If no time is provided, deletes the current frame. Must be used in conjunction with the pts/points or cnd/cacheableNode flag. Deleted frames will not be removed from disk, but renamed as specified by the f/fileName flag. |
|||
descriptionFileName (dfn) | bool | ||
This is a query-only flag that returns the name of the description file for an existing cacheFile node. Or if no cacheFile node is specified, it returns the description file name that would be created based on the other flags specified. |
|||
directory (dir) | unicode | ||
Specifies the directory where the cache files will be located. If the directory flag is not specified, the cache files will be placed in the project data directory. |
|||
doubleToFloat (dtf) | bool | ||
|
|||
endTime (et) | time | ||
|
|||
fileName (f) | unicode | ||
Specifies the base file name for the cache files. If more than one object is being cached and the format is OneFilePerFrame, each cache file will be prefixed with this base file name. In query mode, returns the files associated with the specified cacheFile node. When used with rpf/replaceCachedFrame or apf/appendFrame specifies the name of the backup files. If not specified, replaced frames will be stored with a default name. In query mode, this flag can accept a value. |
|||
format (fm) | unicode | ||
|
|||
geometry (gm) | bool | ||
|
|||
inAttr (ia) | unicode | ||
Specifies the name of the attribute that the cache file will drive. This file is optional when creating cache files. If this flag is not used during create mode, the cache files will be created on disk, but will not be driving anything in the scene. This flag is required when the attachFile flag is used. |
|||
inTangent (it) | unicode | ||
Specifies the in-tangent type when interpolating frames before the replaced frame(s). Must be used with the ist/interpStartTime and iet/interpEndTime flags. Valid values are “linear”, “smooth” and “step”. |
|||
interpEndTime (iet) | time | ||
Specifies the frame until which there will be linear interpolation, beginning at endTime. Must be used with the rpf/replaceCachedFrame or apf/appendFrame flag. Interpolation is achieved by removing frames between endTime and interpEndTime from the cache. Removed frames will be renamed as specified by the f/fileName flag. |
|||
interpStartTime (ist) | time | ||
Specifies the frame from which to begin linear interpolation, ending at startTime. Must be used with the rpf/replaceCachedFrame or apf/appendFrame flags. Interpolation is achieved by removing frames between interpStartTime and startTime from the cache. These removed frames will will be renamed as specified by the f/fileName flag. |
|||
noBackup (nb) | bool | ||
Specifies that backup files should not be created for any files that may be over-written during append, replace or delete cache frames. Can only be used with the apf/appendFrame, rpf/replaceCachedFrame or dcf/deleteCachedFrame flags. |
|||
outAttr (oa) | unicode | ||
|
|||
outTangent (ot) | unicode | ||
Specifies the out-tangent type when interpolating frames after the replaced frame(s). Must be used with the ist/interpStartTime and iet/interpEndTime flags. Valid values are “linear”, “smooth” and “step”. |
|||
pc2File (pcf) | unicode | ||
|
|||
pointCount (pc) | bool | ||
|
|||
points (pts) | unicode | ||
|
|||
prefix (p) | bool | ||
|
|||
refresh (r) | bool | ||
When used during cache creation, forces a screen refresh during caching. This causes the cache creation to be slower but allows you to see how the simulation is progressing during the cache. |
|||
replaceCachedFrame (rcf) | bool | ||
Replaces cached data for the times specified by the startTime/endTime flags. If no time is provided, replaces cache file for the current time. Must be used in conjunction with the pts/points or cnd/cacheableNode flag. Replaced frames will not be deleted, but renamed as specified by the f/fileName flag. |
|||
replaceWithoutSimulating (rws) | bool | ||
When replacing cached frames, this flag specifies whether the replacement should come from the cached node without simulating or from advancing time and letting the simulation run. This flag is valid only when neither the startTime nor endTime flags are used or when both the startTime and endTime flags specify the same time value. |
|||
runupFrames (rf) | int | ||
|
|||
sampleMultiplier (spm) | int | ||
Specifies the sample rate when caches are being created as a multiple of simulation Rate. If the value is 1, then a sample will be cached everytime the time is advanced. If the value is 2, then every other sample will be cached, and so on. The default is 1. |
|||
simulationRate (smr) | time | ||
Specifies the simulation rate when caches are being created. During cache creation, the time will be advanced by the simulation rate, until the end time of the cache is reached or surpassed. The value is given in frames. The default value is 1 frame. |
|||
singleCache (sch) | bool | ||
When used in conjunction with the pts or cacheableNode flag, specifies whether multiple geometries should be put into a single cache or to create one cache per geometry (default). |
|||
startTime (st) | time | ||
|
|||
staticCache (sc) | bool | ||
If false, during cache creation, do not save a cache for the object if it appears to have no animation or deformation. If true, save a cache even if the object appears to have no animation or deformation. Default is true. In query mode, when supplied a shape, the flag returns true if the shape appears to have no animation or deformation. |
|||
worldSpace (ws) | bool | ||
If the points flag is used, turning on this flag will result in the world space positions of the points being written. The expected use of this flag is for cache export. |
Derived from mel command maya.cmds.cacheFile
Example:
import pymel.core as pm
# Create a disk cache containing the points of a plane from
# frames 1 - 100. Typically the shape would be deforming.
#
pm.polyPlane()
# Result: [nt.Transform(u'pPlane1'), nt.PolyPlane(u'polyPlane1')] #
cacheFiles = pm.cacheFile(f='shapeCache', st=1, et=100, points='pPlaneShape1')
# Add a historySwitch node to the history of the shape, and attach the
# newly created cache into the historySwitch node.
#
switch = maya.mel.eval('createHistorySwitch("pPlaneShape1",false)')
cacheNode = pm.cacheFile(f=cacheFiles[0], cnm='pPlaneShape1', ia='%s.inp[0]' % switch ,attachFile=True)
pm.setAttr( '%s.playFromCache' % switch, 1 )
# query the files associated with a cacheFile node
#
pm.cacheFile( cacheNode, query=True, f=True )
# Now use the staticCache flag to indicate that the cache should not be
# created if the object appears to have no animation.
# Since the plane is not animated or deformed, no cache will be created.
#
pm.polyPlane()
cacheFiles = pm.cacheFile(f='shapeCache', staticCache=0, st=1, et=100, points='pPlaneShape2')
# Convert a maya cache into pc2 format. The maya cache is named
# pSphereShape1.xml and located in the directory "c:/test/".
#
pm.cacheFile(pc2=0,pcf='c:/test/mypc2.pc2',f='pSphereShape1',dir='c:/test/')
# Convert a pc2 cache into a maya cache, with the cache data in a single
# file.
#
pm.cacheFile(pc2=1,pcf='c:/test/mypc2.pc2',f='mayaCache2',dir='c:/test/',format='OneFile')