我是一个搅拌器新手,并且一直使用以下脚本将对象的每帧的所有混合形状权重转储到文本文件中 - 每个新行在动画序列中都带有一个帧。
import bpy
sce = bpy.context.scene
ob = bpy.context.object
filepath = "blendshape_tracks.txt"
file = open(filepath, "w")
for f in range(sce.frame_start, sce.frame_end+1):
sce.frame_set(f)
vals = ""
for shapeKey in bpy.context.object.data.shape_keys.key_blocks:
if shapeKey.name != 'Basis':
v = str(round(shapeKey.value, 8)) + " "
vals += v
vals = vals[0:-2]
file.write(vals + "\n");
正如你所看到的,这在Blender中非常容易,但现在我想在Maya中做同样的事情。事先我尝试将不同格式的3D模型放在一边; DAE和FBX(尝试了ascii和bin以及不同的年份版本)但是Blender不会导入它们(每次都会收到很多错误)。
所以基本上我要问的是如何通过python或MEL在maya中做同样的事情?我查看了运动构建器api,但还没知道从哪里开始。
提前干杯。
编辑:好的,我明白了。一旦你掌握了cmds lib,就会非常容易。
import maya.cmds as cmds
filepath = "blendshape_tracks.txt"
file = open(filepath, "w")
startFrame = cmds.playbackOptions(query=True,ast=True)
endFrame = cmds.playbackOptions(query=True,aet=True)
for i in range(int(startFrame), int(endFrame)):
vals = ""
cmds.currentTime(int(i), update=True)
weights = cmds.blendShape('blendshapeName',query=True,w=True)
vals = ""
for w in weights:
v = str(round(w, 8)) + " "
vals += v
vals = vals[0:-2]
file.write(vals + "\n")
答案 0 :(得分:0)
回答自己的问题。
import maya.cmds as cmds
filepath = "blendshape_tracks.txt"
file = open(filepath, "w")
startFrame = cmds.playbackOptions(query=True,ast=True)
endFrame = cmds.playbackOptions(query=True,aet=True)
for i in range(int(startFrame), int(endFrame)):
vals = ""
cmds.currentTime(int(i), update=True)
weights = cmds.blendShape('blendshapeName',query=True,w=True)
vals = ""
for w in weights:
v = str(round(w, 8)) + " "
vals += v
vals = vals[0:-2]
file.write(vals + "\n")