簡體   English   中英

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}}

現在,我能夠從我想要的屬性中提取值,但是它會導致出現列,並且當我放置多個命令時,它會返回並出錯

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方式對其進行格式化?

謝謝

關於第一個錯誤:

“ cameraName未定義”

您在哪里定義變量cameraName 也許您只是沒有在代碼中顯示它,或者您確實忘記了定義該變量。

我找到了答案:

keyframe -q -vc Camera0Node.translateX

你給了我我所需要的。

謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM