Seems to work. Thanks so much guys.
Check out some of my work... www.vimeo.com/darrencoombes/reel2015 <http://www.vimeo.com/darrencoombes/reel2015> Mob: +61 418 631 079 <tel:+61%20418%20631%20079> Instagram: @7secondstoblack Instagram: @durwood0781 Skype: darren.coombes81 Twitter: @durwood81 > On 7 Mar 2016, at 7:52 pm, Ben Dickson <ben.dick...@rsp.com.au> wrote: > > Ah cool, the .constant() method is useful. > > So to answer the original question, this in ~/.nuke/menu.py should work: > > def clear_flat(knob): > if knob.hasExpression(): return > if not knob.isAnimated(): return > > for n in range(99): > if knob.animation(n) and knob.animation(n).constant(): > knob.clearAnimated(n) > > > def clear_flat_menucmd(): > for node in nuke.selectedNodes(): > for k in node.knobs().values(): > clear_flat(k) > > > nuke.menu("Nuke").addCommand("Utils/Clear non-animated", clear_flat_menucmd) > > > > On 05/03/16 04:16, Nathan Rusch wrote: >> Just to add one more way to do things, the AnimationCurve class has a >> .constant() method, which returns "True if the animation appears to be a >> horizontal line, is a simple number, or is the default and all the >> points are at the same y value and have 0 slopes." >> -Nathan >> >> *From:* Ben Dickson <mailto:ben.dick...@rsp.com.au> >> *Sent:* Friday, March 04, 2016 5:23 AM >> *To:* Nuke user discussion <mailto:nuke-users@support.thefoundry.co.uk> >> *Subject:* Re: [Nuke-users] Remove flat animation curves >> 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 <ben.dick...@rsp.com.au >> > <mailto:ben.dick...@rsp.com.au>>: >> > >> > 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 <darren.coom...@me.com >> > <mailto:darren.coom...@me.com> >> > <mailto:darren.coom...@me.com <mailto:darren.coom...@me.com>>>: >> > >> > 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 >> > Nuke-users@support.thefoundry.co.uk >> > <mailto:Nuke-users@support.thefoundry.co.uk>, >> > http://forums.thefoundry.co.uk/ >> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >> > >> > >> > -- >> > ben dickson >> > 2D TD | ben.dick...@rsp.com.au <mailto:ben.dick...@rsp.com.au> >> > rising sun pictures | www.rsp.com.au <http://www.rsp.com.au> >> <http://www.rsp.com.au> >> > _______________________________________________ >> > Nuke-users mailing list >> > Nuke-users@support.thefoundry.co.uk >> > <mailto:Nuke-users@support.thefoundry.co.uk>, >> > http://forums.thefoundry.co.uk/ >> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >> > >> > >> > >> > >> > _______________________________________________ >> > Nuke-users mailing list >> > Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >> > >> >> -- >> ben dickson >> 2D TD | ben.dick...@rsp.com.au >> rising sun pictures | www.rsp.com.au <http://www.rsp.com.au> >> _______________________________________________ >> Nuke-users mailing list >> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >> >> >> _______________________________________________ >> Nuke-users mailing list >> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >> > > -- > ben dickson > 2D TD | ben.dick...@rsp.com.au > rising sun pictures | www.rsp.com.au > _______________________________________________ > Nuke-users mailing list > Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
_______________________________________________ Nuke-users mailing list Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users