def test_simplify_with_big_file():
    path = os.path.dirname(__file__) + "/fixtures/framecurves/huge.framecurve.txt"
    curve = framecurve.parse(open(path))
    assert "huge.framecurve.txt" == curve.filename
    
    assert len(curve) == 102
    simplified = framecurve.simplify(curve)
    assert len(simplified) == 16
Example #2
0
def load_curve_into_knob(curve, knob):
    """
    Load a passed framecurve.Curve object into the passed Knob object, resetting
    all the animations
    """
    knob.clearAnimated()
    knob.setAnimated()
    for correlation in framecurve.simplify(curve):
        knob.setValueAt(correlation.value, correlation.at)  # , index=1, view=1)
    make_keyframes_linear(knob)
Example #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))
def test_simplify_with_two_frames():
    e1 = framecurve.FrameCorrelation(1, 2.4)
    e2 = framecurve.FrameCorrelation(2, 2.5)
    e3 = framecurve.FrameCorrelation(3, 2.6)
    c = framecurve.Curve(values = [e1, e2, e3])
    
    simplified = framecurve.simplify(c)
    
    assert len(simplified) == 2
    
    assert simplified[0].at == 1
    assert simplified[1].at == 3
    assert simplified[0].value == 2.4
    assert simplified[1].value == 2.6