def test_writes_only_existing_frames():
  curve = framecurve.Curve(values = [framecurve.FrameCorrelation(10, 123), framecurve.FrameCorrelation(12, 456)])
  expect = "# http://framecurve.org/specification-v1\r\n# at_frame\tuse_frame_of_source\r\n10\t123.00000\r\n12\t456.00000\r\n"
  s = StringIO.StringIO()
  framecurve.serialize(s, curve)

  print repr(expect)
  print repr(s.getvalue())
  
  assert s.getvalue() == expect
def test_writes_preamble_if_needed():
    curve = framecurve.Curve(values = [framecurve.FrameCorrelation(10, 123)])
    expect = "# http://framecurve.org/specification-v1\r\n# at_frame\tuse_frame_of_source\r\n10\t123.00000\r\n"

    fileobj = StringIO.StringIO()
    framecurve.serialize(fileobj = fileobj, curve = curve)

    print repr(fileobj.getvalue())
    print repr(expect)
    assert fileobj.getvalue() == expect
Ejemplo n.º 3
0
def export_framecurve_from_this_knob():
    fc_path = nuke.getFilename("Name the framecurve file to write to", "*.framecurve.txt", default="shot.framecurve.txt", favorites="", type="", multiple=False)
    fc = framecurve.Curve()
    
    curve_name_with_suffix = nuke.animations()[0]
    knob_name = curve_name_with_suffix.split(".")[0]
    this_knob = nuke.thisNode()[knob_name]
    with open(fc_path, "w") as fc_file:
        for curve in nuke.animations():
            for frame in all_script_frames():
                fc.append(framecurve.FrameCorrelation(at=frame, value=this_knob.getValueAt(frame)))
            framecurve.serialize(fc_file, framecurve.simplify(fc))