Hello,

I'm trying to make "presets" from a selection of nodes contained in a
backdrop node.
The presets selection will be a dropdown menu attached to the backdrop.

My idea is to
1. ('save preset')export all the knobs values from a nodes selection to a
.nk file probably the nuke. (e: nuke.nodeCopy("c:/temp.txt"))
2. ('load preset')get and paste all values from that file to the exactly
same nodes selection

I there an easy way/function  to get these knob values and replace the ones
existing in the dag?
In the next example, if u double click on the backdrop node, what function
can I put in the load button?



set cut_paste_input [stack 0]
version 6.2 v2
BackdropNode {
 inputs 0
 name BackdropNode2
 selected true
 xpos -4319
 ypos -2006
 bdwidth 461
 bdheight 301
 addUserKnob {20 User}
 addUserKnob {4 Load M {Afternoo Day Night}}
 addUserKnob {22 Refresh -STARTLINE T "pulldown =
nuke.thisNode().knobs()\['Load']\nPresets=sorted(os.listdir(\"C:/Presets\"))\na=\[]\nfor
i in Presets:\n
a.append(i.split('_')\[1].strip('.nk'))\n\npulldown.setValues(a)\n"}
 addUserKnob {22 LoadPreset l "Load Preset" -STARTLINE}
 addUserKnob {26 ""}
 addUserKnob {22 Save -STARTLINE T "#function to find all nodes inside the
backdrop\ndef getBackDropInside ( bd ) :\n   list = \[]\n   left =
bd\['xpos'].value()\n   top = bd\['ypos'].value() + 20\n   bd_Width =
bd\['bdwidth'].value()\n   bd_Height = bd\['bdheight'].value()\n   right =
left + bd_Width - 80\n   bottom = top - 20 + bd_Height - 40\n   for i in
nuke.allNodes():\n       if i\['xpos'].value() > left and
i\['xpos'].value() < right and i\['ypos'].value() > top and
i\['ypos'].value() < bottom:\n           list.append( i )\n   return
list\n\n#Copy all knobs value to the specified
name\n\[n\['selected'].setValue(False) for n in nuke.allNodes() ]\nNodes =
getBackDropInside (nuke.thisNode() )\nfor select in
Nodes:\n\tselect\['selected'].setValue(True)\n\nPresetRoot=\"c:/Presets/\"\nPresetname=nuke.thisNode()\['PresetName'].value()\nprint
PresetRoot+Presetname+\".nk\"\nnuke.nodeCopy
(PresetRoot+\"Preset_\"+Presetname+\".nk\")"}
 addUserKnob {1 PresetName l "" t "the final name will be \"Preset_\" +
your preset name" -STARTLINE}
 PresetName Night
}
push $cut_paste_input
Rectangle {
 area {512 389 1536 1167}
 name Rectangle1
 selected true
 xpos -4012
 ypos -1826
}
Constant {
 inputs 0
 channels rgb
 color 1
 name Constant1
 selected true
 xpos -4227
 ypos -1940
}
Constant {
 inputs 0
 channels rgb
 name Constant2
 selected true
 xpos -4086
 ypos -1940
}
Merge2 {
 inputs 2+1
 name Merge1
 selected true
 xpos -4152
 ypos -1826
}





-- 
Denis Tassenoy
_______________________________________________
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