I am trying to write a script for importing multiple cache files for a model in Maya using Python. So far I have got the following:
import maya.cmds as cmds
cache_files_path = 'D:/Project/sfin/work/data/ram/geo'
latest_look_file = 'D:/Project/chars/ram/look/maya/ram_clean_look_v002_t005.mb'
# open the latest look file
cmds.file(latest_look_file, f = True, op = "v=0;", typ = 'mayaBinary', o = True)
cmds.select(all = True)
Say the file that you have opened has a
"foo_mesh", which can be checked using
isinstance(pc.PyNode("foo_mesh"), pc.nt.Mesh. And there is a cache file for it named
"foo_mesh_cache.xml" (consider this as the cache metadata) and
To apply this cache to the mesh something like the following should work:
import pymel.core as pc mesh = "foo_mesh" xml = "foo_mesh_cache.xml" data = "foo_mesh_data.mc" pc.mel.doImportCacheFile(xml, "", [mesh], list())
And to find out whether a cache file has already been applied to a mesh, list it's history and see if it contains node of type