问题描述
我正在尝试编写脚本,以使用Python在Maya中为模型导入多个缓存文件.到目前为止,我得到了以下信息:
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)
现在,我需要开始将现有的几何缓存从"cache_files_path"导入到各个对象. Maya2013具有mel脚本"doImportCacheFile.mel",可完成我猜想的任务.但是我不能从这里开始.
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.
推荐答案
说您打开的文件有一个名为"foo_mesh"
的mesh
,可以使用isinstance(pc.PyNode("foo_mesh"), pc.nt.Mesh
进行检查.并且有一个名为"foo_mesh_cache.xml"
的缓存文件(将其视为缓存元数据)和"foo_mesh_data.mc"
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())
要找出是否已将缓存文件应用于网格,请列出其历史记录,并查看其是否包含类型为pc.nt.CacheFile
的节点.
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
.
这篇关于使用Python在Maya中导入多个缓存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!