Also, if you want to make sure you're copying any kind of value across (including animations and expressions), have a look at the <knob>.fromScript() and <knob>.toScript() methods.
And if you want to copy all knobs between nodes of the same Class (or you know that both nodes have the same knobs), then you can simplify the whole thing by using the <node>.readKnobs() and <node>.writeKnobs() methods, which will exclude s = # your source node # t = # your target knob # t.readKnobs(s.writeKnobs()) By default, writeKnobs() won't include knobs like "name", "xpos" or "ypos", which is probably what you want. Cheers, Ivan On Thu, Oct 20, 2011 at 7:25 AM, Colin Alway <[email protected]> wrote: > I think the problem is the getValue() is meant for animated (number) > values, not string values. Assuming you're looking at Grade nodes here: > > n['channels'].getValue() returns 1.0 > n['channels'].value() returns 'rgb' > > Bear in mind if you copy the xpos & ypos knobs your new node will be > positioned over the original node in the DAG! > > hope this helps > Colin > > > On 20 October 2011 14:53, kernowkid <[email protected]>wrote: > >> ** >> Hi all, >> Im trying to save a selected nodes knob values into a variable and then >> set those values into another node. >> >> This is how far I got. The first bit puts the values and knob names into >> variables. The second bit , which isn't working, sets the value of the >> targeted node. >> >> *Code:* >> set1n = [] >> set1v = [] >> >> n = nuke.selectedNode() >> for i in range(n.getNumKnobs()): >> set1n.insert(i, n.knob(i).name()) >> set1v.insert(i, n.knob(i).getValue()) >> >> tn = nuke.toNode("Grade2") >> for i in range(tn.getNumKnobs()): >> tn[set1n[i]].setValue(set1v[i]) >> >> >> I get back: >> >> *Quote:* # Result: >> Traceback (most recent call last): >> File "**", line 11, in ** >> TypeError: setValue() argument 1 must be string, not float >> >> So something is going wrong. Either I'm saving the wrong info in to the >> variables or I have the *Code:* tn[set1n[i]].setValue(set1v[i]) bit >> wrong? >> Any help appreciated >> [image: Smile] >> >> _______________________________________________ >> Nuke-python mailing list >> [email protected], http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> >> > > > -- > colin alway > > _______________________________________________ > 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
