【问题标题】:Python : export keyframe from maya in linePython:从maya中导出关键帧
【发布时间】:2018-10-03 17:03:04
【问题描述】:

我正在尝试制作一个脚本,该脚本将所有所需参数写入一行而不是一行,以制作通往 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}}

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

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()

返回

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

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

谢谢

【问题讨论】:

  • 发布的代码没有正确缩进并且不会运行 - 您是否可能只是尝试执行 def 之后的行?那会产生你提到的错误。如果你重新格式化代码,你会得到更好的答案
  • 谢谢,我已经编辑过了,现在的问题是“只有”拥有所有关键帧值并以正确的方式格式化它

标签: python camera maya autodesk nuke


【解决方案1】:

我找到了答案:

keyframe -q -vc Camera0Node.translateX

你给了我我需要的东西。

谢谢。

【讨论】:

    【解决方案2】:

    关于第一个错误:

    'cameraName 未定义'

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

    【讨论】:

    • 我已经纠正了它,现在基本部分可以工作了,但我不知道如何让所有关键帧值都变成一个值。那么如何以正确的方式格式化它(行值 x1 x2 x3 x4 等等......)
    猜你喜欢
    • 1970-01-01
    • 2010-11-19
    • 2017-12-17
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多