set cut_paste_input [stack 0] version 14.0 v5 BackdropNode { inputs 0 name BackdropNode58 tile_color 0xc0c0c001 label "Switch Generator" note_font_size 100 selected true xpos 15 ypos -13202 bdwidth 808 bdheight 228 } push $cut_paste_input NoOp { name MF_SwitchGenerator knobChanged "n = nuke.thisNode()\nk = nuke.thisKnob()\n \nif k.name() == \"type\":\n # Disable out when no needed.\n if n\[\"type\"].getValue() in range(0,2):\n n\[\"outFrame\"].setEnabled(False)\n n\[\"setOutFrame\"].setEnabled(False)\n n\[\"outFrame\"].setValue(0) \n else:\n n\[\"outFrame\"].setEnabled(True)\n n\[\"setOutFrame\"].setEnabled(True)" selected true xpos 359 ypos -13024 addUserKnob {20 main} addUserKnob {4 type t "Type of switch generated:\n\n- On: Switch from 0 to 1 on a specified frame\n\n- 1-Frame only: Swith from 0 to 1 on a 1-frame only. Like a trigger\n\n-From-To:Switch to value 1 on a specified frame range." M {On "1-Frame only(Trigger)" From-To "" "" "" "" "" "" "" "" "" "" "" ""}} addUserKnob {3 inFrame l frame} inFrame 1001 addUserKnob {22 setInFrame l Set t "Press to set the in frame to the current frame." -STARTLINE T "a = nuke.thisNode()\nb = nuke.frame()\n\na\['inFrame'].setValue(b)"} addUserKnob {3 outFrame l to -STARTLINE +DISABLED} addUserKnob {22 setOutFrame l Set t "Press to set the out frame to the current frame." -STARTLINE +DISABLED T "a = nuke.thisNode()\nb = nuke.frame()\n\na\['outFrame'].setValue(b)"} addUserKnob {22 generateSwitch l "Generate Switch" T "#Set a default one shot trigger.\ndef generateSwitch(inFrame, outFrame, type):\n if t==2:\n if outFrame < inFrame:\n nuke.message(\"Please, check that \\\"off\\\" frame is higher than the \\\"on\\\" frame.\")\n return None\n \n #Create and set Trigger\n nSwitch = nuke.nodes.Switch()\n nSwitch.setXYpos(thisN.xpos()+100,thisN.ypos()+50)\n w = nSwitch\['which']\n w.setAnimated()\n w.setValueAt(0, inFrame - 1)\n w.setValueAt(1, inFrame)\n \n if t == 0:\n if (thisN\['labelOn'].getValue() == 1):\n nSwitch\['label'].setValue(\"