importing multiple cache files in Maya using Python

我们两清 提交于 2019-12-10 11:46:38

问题


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)

Now I need to start importing existing geometry cache from the 'cache_files_path' to the respective objects. Maya2013 has the mel script 'doImportCacheFile.mel' which does the task I guess. But I couldn't proceed from here.


回答1:


Say the file that you have opened has a mesh named "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 "foo_mesh_data.mc"

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 pc.nt.CacheFile.



来源:https://stackoverflow.com/questions/20174424/importing-multiple-cache-files-in-maya-using-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!