For a whole replacement tool to replace gizmos with a newer version, have a look at this and see if it helps. http://www.nukepedia.com/python-scripts/nodegraph/replacenodes/
As a more generic answer, though, if you want to copy any kind of knob value (single value, animation, expression...) across between two nodes, your best bet is probably to use the fromScript() and toScript() knob methods. Something like this should let you easily copy all knobs that exist in both nodes, while excluding some of them as needed (name, xpos, ypos, etc...) def copyKnobValues(sourceNode, destNode, excludeKnobs = []): sourceKnobs = sourceNode.knobs() destKnobs = destNode.knobs() intersection = dict([(item, sourceKnobs[item]) for item in sourceKnobs.keys() if item not in excludeKnobs and destKnobs.has_key(item)]) for knob in intersection.keys(): destNode[knob].fromScript(sourceNode[knob].toScript()) On Fri, Jul 1, 2011 at 2:18 PM, Dan Rosen <danrosenro...@yahoo.com> wrote: > Hello, > > Apologies if this has been covered somewhere. I'm looking to copy all > values from one source node to a target node. The reason for this is > that I'm going to use it on our custom gizmos that have versions and > allow for a version up or down on the target. There is code form > Nukepedia to create a copy with expression links (a la Shake clone) > that should be 99% of what I need. I just cannot figure out the > correct syntax. Any help would be much appreciated. Here's the > aforementioned code as the example that sets expression links. > > def shakeClone(): > EXCLUSION_LIST = > > ["xpos","ypos","help","hide_input","note_font_color","onCreate","updateUI","knobChanged","note_font","tile_color","selected","autolabel","process_mask","label","onDestroy","inject","indicators","maskFrom","maskChannelMask","maskChannelInput","Mask","postage_stamp","disable","maskChannelMask", > "panel", "maskFromFlag","name","cached","fringe", "maskChannelInput" , > "note_font_size" , "filter", "gl_color","transform"] > > originals = nuke.selectedNodes() > [ n['selected'].setValue(False) for n in nuke.allNodes() ] > > for original in originals: > new = nuke.createNode(original.Class()) > > for i in original.knobs(): > if i not in EXCLUSION_LIST: > # Try to set the expression on the knob > new.knob(i).setExpression("%s.%s" % (original.name(), > original.knob(i).name())) > > # This will fail if the knob is an > Array Knob...use setSingleValue to compensate > > if isinstance(new.knob(i), nuke.Array_Knob): > > new.knob(i).setSingleValue(original.knob(i).singleValue()) > > # This will fail if the knob is a > String Knob...use a TCL expression link to compensate > > elif isinstance(new.knob(i), nuke.String_Knob): > new.knob(i).setValue("[value %s.%s]" % > (original.name(), original.knob(i).name())) > > new['selected'].setValue(False) > > [ n['selected'].setValue(True) for n in originals ] > _______________________________________________ > Nuke-python mailing list > Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >
_______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python