Last active
July 16, 2021 01:48
-
-
Save U29/e3a368ab1e5397bfce82cd08a4557670 to your computer and use it in GitHub Desktop.
A tool of Foundry Nuke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set cut_paste_input [stack 0] | |
version 12.1 v4 | |
push $cut_paste_input | |
NoOp { | |
name Dissolve_Inserter | |
tile_color 0x6bffc0ff | |
note_font Verdana | |
note_font_size 9 | |
note_font_color 0xff | |
selected true | |
xpos -2828 | |
ypos 2131 | |
addUserKnob {20 User l Dissolve_Inserter} | |
addUserKnob {3 insert_num} | |
insert_num 1 | |
addUserKnob {6 modify_keyframes -STARTLINE} | |
modify_keyframes true | |
addUserKnob {22 insert_button l Insert! T "### keyframe modify ###\ndef modify_keyframes(node):\n if not node\['which'].isAnimated():\n raise Exception(\"You must set any key to Dissolve 'which' knob\")\n animCurve = node\['which'].animation(0)\n allCurves = node\['which'].animations()\n\n keys_num = len(animCurve.keys())\n for key in animCurve.keys():\n key_frame = key.x\n key_which = key.y\n\n if key_which >= insert_num:\n node\['which'].setValueAt(key_which + 1, key_frame)\n\n\n### Begin Script ###\nnode = nuke.selectedNode()\n\ntool = nuke.thisNode()\ninsert_num = tool\['insert_num'].getValue()\n\ntmpInputs = \[]\ninput_num = node.inputs()\n\nfor i in range(input_num):\n if i == 2:\n if insert_num >= 2:\n tmpInputs.append(\"None(Mask)\")\n continue\n tmpInputs.append(node.input(i))\n \n\n\n### insert to 2 <= ###\nif insert_num >= 2:\n for i in range(input_num+1):\n if i -1 == insert_num:\n node.setInput(i, None)\n if i - 1 > insert_num:\n node.setInput(i, nuke.toNode(tmpInputs\[i-1].name()))\n\n### insert to 1 ###\nelif insert_num == 1:\n for i in range(input_num):\n if i == 0:\n node.setInput(1, None)\n if i == 1:\n node.setInput(3, nuke.toNode(tmpInputs\[1].name()))\n if i >= 2:\n node.setInput(i+1, nuke.toNode(tmpInputs\[i-1].name()))\n\n### insert to 0 ###\nelif insert_num == 0:\n for i in range(input_num):\n if i == 0:\n node.setInput(0, None)\n if i == 1:\n node.setInput(1, nuke.toNode(tmpInputs\[0].name()))\n node.setInput(3, nuke.toNode(tmpInputs\[1].name()))\n if i >= 2:\n node.setInput(i+1, nuke.toNode(tmpInputs\[i-1].name()))\n\nif tool\[\"modify_keyframes\"].getValue() == 1:\n modify_keyframes(node)" +STARTLINE} | |
addUserKnob {20 Info} | |
addUserKnob {26 credit l "" +STARTLINE T "created by Kento Fukuda\nv001 2021-07-14"} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment