Python : 从 maya 中导出关键帧

Python : export keyframe from maya in line

我正在尝试制作一个脚本,将所有需要的参数写在一行中,而不是一行中,以创建一个到 nuke 的管道(关键帧在行中) 要在 nuke 中有效,关键帧需要像这样

translate {{curve R x1 list of valueX}} {curve R x1 list of valueY}} {curve R x1 list of valueZ}}

例子

translate {{curve R x1 10 11.03448296 12.06896591 13.10344791 14.13793087 15.17241383} {curve R x1 20 22.06896591 24.13793182 26.20689583 28.27586174 30.34482765} {curve R x1 30 33.10344696 36.20689774 39.3103447 42.41379166 45.51724243}}

现在我可以从我想要的属性中提取值,但它会导致列,当我输入几个命令时,它 return 和错误

def convert():
    print "Loading file: "

    # Select the incoming tracked camera
    cmds.select('Camera0Node', r=1)

    # Get first and last key set to determine bake range
    firstKey = int(cmds.findKeyframe(time=(0, 100000), which='first'))
    lastKey = int(cmds.findKeyframe(time=(0, 100000), which='last')) 
    print "Frame range: [", int(firstKey), ":", int(lastKey), "]"

    # Enable depth of field
    tx = cmds.getAttr(".tx")
    ty = cmds.getAttr(".ty")
    tz = cmds.getAttr(".tz")
    rx = cmds.getAttr(".rx")
    ry = cmds.getAttr(".ry")
    rz = cmds.getAttr(".rz")
    hfa = cmds.getAttr('.horizontalFilmAperture')
    vfa = cmds.getAttr('.verticalFilmAperture')
    fl = cmds.getAttr('.focalLength')
    vfov = 2 * (math.atan2(vfa/2.0*25.4,fl) * 180 / math.pi);

    # Bake out to Euler angles
    cmds.bakeResults('Camera0Node',sparseAnimCurveBake=False, minimizeRotation=True, removeBakedAttributeFromLayer=False, removeBakedAnimFromLayer=False, oversamplingRate=1, bakeOnOverrideLayer=False, preserveOutsideKeys=False, simulation=True, sampleBy=1, shape=True, t=(firstKey, lastKey), disableImplicitControl=True, controlPoints=False)
    print str(tx)

convert()

return

Loading file: 
Frame range: [ 1 : 504 ]
2385.11

所以我只有一个 x 值,我如何获取所有关键帧值并将其格式化为 nuke 方式?

谢谢

关于第一个错误:

'cameraName is not defined'

你在哪里定义变量cameraName?也许你只是没有在你的代码中显示它或者你真的忘记定义那个变量。

我找到了答案:

keyframe -q -vc Camera0Node.translateX

你给了我我所需要的。

谢谢。