3

I am trying to make a script that writes all the desired parameters in a line, not in row, to make a pipe to nuke (keyframe in line) to be valid in nuke, Keyframe need to be like this

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

example

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

For now i'm able to extract value from attribute i want but it result in column and, when i put several commands, it return and error

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

So i only have one value of x, How can i get all keyframe value and format it the nuke way ?

thank you

William Eguienta
  • 135
  • 1
  • 13
  • The code as posted is not correctly indented and won't run -- is it possible you're only trying to execute the lines after the `def`? That would generate the error you mention. You'll get better answers if you reformat the code – theodox Apr 23 '18 at 16:22
  • thank you, i have edited it, now the problem is "only" on having all the keyframe value and format it the right way – William Eguienta Apr 24 '18 at 06:39

2 Answers2

1

I've found the answer:

keyframe -q -vc Camera0Node.translateX

You gave me exactly what I needed.

Thank you.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
William Eguienta
  • 135
  • 1
  • 13
0

About the first error:

'cameraName is not defined'

Where are you defining the variable cameraName? Maybe you just didn't show it in your code or you really forgot to define that variable.

Ralf
  • 16,086
  • 4
  • 44
  • 68
  • i have corrected it, now the basic part works but i don't find how to have all keyframe value insteed of a single one. then how to format it the right way (in line value x1 x2 x3 x4 and so on... ) – William Eguienta Apr 24 '18 at 06:40