Oh, yes, you are quite right!

The following seems to work, but it is late and I've only tested on the 'size' knob of a Blur with a few contrived keyframes..

def clear_flat(knob):
    if not knob.isAnimated(): return
    if knob.hasExpression(): return

    key_values = [a.y for a in knob.animation(0).keys()]

    if len(key_values) < 2:
        # 0 or 1 keys can just be cleared
        knob.clearAnimated()
    elif sum([abs(key_values[0] - a) for a in key_values]) > 1e-5:
        # Keys change over time
        return
    else:
        # Animated flag can be cleared
        knob.clearAnimated()

clear_flat(nuke.selectedNode()['size'])

On 04/03/16 23:32, Elias Ericsson Rydberg wrote:
If I remember my math correctly the curve should always be flat when the
derivative is 0? If the value is constantly increasing, the derivative
would always be a positive number. Checking for the delta in Y-position
is the same thing as finding the derivative, isn't it?

Cheers,
Elias Ericsson Rydberg

2016-03-04 13:45 GMT+01:00 Ben Dickson <[email protected]
<mailto:[email protected]>>:

    In a Python script you could just loop over each knob's .animation()
    curves, check if all the .y values are the same - if so, clear the
    animation and replace it with a static value. I think checking for
    zero derivative is incorrect, as that could still require keyframes
    (i.e a constantly increasing value - different to a constant value
    but would have same derivative)

    On 04/03/16 23:07, Elias Ericsson Rydberg wrote:

        Maybe you could loop through each animation curve and check it the
        derivative of said curve is anything different than 0 then it
        shouldn't
        be marked for deletion (or all values except for frame is deleted).
        Haven't tried it myself, but that's one method.

        Cheers,
        Elias Ericsson Rydberg

        fredag 4 mars 2016 skrev Darren Coombes <[email protected]
        <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>>:

             Anyone know how you'd write a menu item to remove all flat
        animation
             curves from a camera for example??

             This way, only curves that are animated show up in curve
        editor?

             *
             *Thanks.*
             *Darren Coombes*
             **
             *
             *
             *Check out some of my work...*
             *
             *
             *www.vimeo.com/darrencoombes
        <http://www.vimeo.com/darrencoombes>
        <http://www.vimeo.com/darrencoombes>*
             *
             *
             *
             *
             *
             *
             *Mob: +61 418 631 079 <tel:%2B61%20418%20631%20079>
        <tel:+61%20418%20631%20079>*
             *
             *
             *Skype:  darrencoombes*
             *Twitter:  @durwood81*
             *



        _______________________________________________
        Nuke-users mailing list
        [email protected]
        <mailto:[email protected]>,
        http://forums.thefoundry.co.uk/
        http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


    --
    ben dickson
    2D TD | [email protected] <mailto:[email protected]>
    rising sun pictures | www.rsp.com.au <http://www.rsp.com.au>
    _______________________________________________
    Nuke-users mailing list
    [email protected]
    <mailto:[email protected]>,
    http://forums.thefoundry.co.uk/
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users




_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to