Whoa - I guess I didn't miss something. All of these are of course do-able and 
I'm doing your (1) suggestion already, but I was hoping for some one stop 
shopping with something like a "node.reset()" and to be done with it!

Ok, sending this in as a feature request - seems like a lot of work for 
something the gui already has a function for.

thank you!
jrab


On Aug 5, 2011, at 6:47 PM, Nathan Rusch wrote:

> I don't know of a one-call way of doing this, but I may have missed an 
> addition somewhere. However, is there a reason you can't just create a new 
> version of the node and swap it for the existing one?
> 
> If you can't, a couple options might be:
> 
> 1) Loop through and manually unsplit all views, clear animation, and set to 
> defaultValue() on all knobs, using hasattr calls to avoid AttributeErrors. 
> Some knobs could be somewhat trickier (ChannelMask knobs, for example), but 
> you may also just know what those are supposed to be and hard-code that into 
> your script.
> 
> 2) Use <node>.writeKnobs() to dump your default values and then .readKnobs() 
> to restore them. This will remove any expressions, but you'll still have to 
> unsplit any knob views manually (fairly trivial using hasattr).
> 
> 3) If you know what knobs could be changed (and which ones you explicitly 
> want to restore), you could store all their .toScript() values somewhere 
> persistent as a dictionary of name:toScript() (maybe serialize it and store 
> it on the node in a hidden text knob or something), and then just load from 
> that every time. Storing it on the node keeps things self-contained, and 
> prevents your startup script from having to hit a disk any more than is 
> necessary, but something like DB or file storage would work as well.
> 
> 4) Create a fresh version of the node, but instead of swapping it out, get a 
> list of all the knobs on your current node that aren't default 
> (nuke.tcl('knobs -d nodeName') can still come in handy for this), use those 
> .toScript values from the fresh node on your existing node, and clean up the 
> new one.
> 
> Anyway, just some early morning brainstorming. Hope some of this is useful.
> 
> -Nathan
> 
> -----Original Message----- From: John RA Benson
> Sent: Friday, August 05, 2011 12:48 AM
> To: Nuke Python discussion
> Subject: [Nuke-python] setting all knobs on a node to default state
> 
> Hey there -
> 
> I must've missed something simple - isn't there a command to reset all knobs 
> of a node to a default state? Get rid of splits, animation, expressions etc 
> all in one go? Like from the gui, selecting "Set knobs to default"? I need to 
> reset a node when I 'reload' it so things don't get messy.
> 
> thanks
> jrab_______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python 
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

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

Reply via email to