Created
July 7, 2016 16:40
-
-
Save jedypod/9fbc90284a436f64bd0332c68944d42a to your computer and use it in GitHub Desktop.
DOLLAR_GUI_HANDLER is a node to remove $gui expressions on Nuke nodes in a script. It is based on $gui Expression Finder by Falk Hofmann, but the code is re-written to be more robust, and to have functionality to remove $gui expressions as if the script were being rendered on the farm, instead of reverting back to the GUI values.
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
NoOp { | |
name DOLLAR_GUI_HANDLER | |
tile_color 0xd94848ff | |
hide_input true | |
addUserKnob {20 Handler l "\$gui Handler"} | |
addUserKnob {1 nodelist} | |
nodelist "H_high_low_switch.Switch1, RF_Yorktown_DEFOCUS.SHIT_SWITCHER, RF_Yorktown_BG1.ScanlineRender4, ScanlineRender1" | |
addUserKnob {26 ""} | |
addUserKnob {22 find_gui_nodes l "Find \$gui Nodes" T "# Find all nodes with knobs that have \$gui expressions\nnodelist = \[]\nfor node in nuke.allNodes(recurseGroups=True):\n for knob in node.knobs():\n if node\[knob].hasExpression():\n if '\$gui' in node\[knob].toScript():\n if node not in nodelist:\n nodelist.append(node)\n\nnodelist_comma = ', '.join(\[item.fullName() for item in nodelist])\nprint nodelist_comma\nnuke.thisNode()\['nodelist'].setValue(nodelist_comma)" +STARTLINE} | |
addUserKnob {22 remove_gui_expression l "Remove \$gui Expression" -STARTLINE T "# Remove \$gui expression\n#thisNode = nuke.selectedNode()\nthisNode = nuke.thisNode()\nnodelist_comma = thisNode\['nodelist'].value()\nnodelist = \[nuke.toNode(node) for node in nodelist_comma.split(', ')]\nfor node in nodelist:\n for knobname in node.knobs():\n knob = node\[knobname]\n # Test is knob is multi-dimensional\n try:\n knobwidth = knob.width()\n except AttributeError:\n knobwidth=1\n for idx in range(knobwidth):\n if knob.hasExpression(idx):\n knob_expr = knob.animation(idx).expression()\n if '\$gui' in knob_expr:\n print \"WORKING ON:\", knob.name(), idx\n\n new_knob_expr = knob_expr.replace(\"\$gui\", \"0\")\n\n print node.name() + '.' + knob.name() + \": \" + knob_expr\n print node.name() + '.' + knob.name() + \": \" + new_knob_expr\n\n knob.setExpression(new_knob_expr, idx)\n print \"New Expression is: \", new_knob_expr\n knob.clearAnimated(idx)"} | |
addUserKnob {26 ""} | |
addUserKnob {22 select_nodes l "Select Nodes" -STARTLINE T "# Select all nodes that have been found with \$gui expressions\nthisNode = nuke.thisNode()\nnodelist_comma = thisNode\['nodelist'].value()\nnodelist = \[nuke.toNode(node) for node in nodelist_comma.split(', ')]\n\[n.setSelected(False) for n in nuke.allNodes(recurseGroups=True)]\nfor node in nodelist:\n node.setSelected(True)"} | |
addUserKnob {22 label_gui_nodes l "Add Label to Nodes" -STARTLINE T "# Mark node in label\nthisNode = nuke.thisNode()\nnodelist_comma = thisNode\['nodelist'].value()\nnodelist = \[nuke.toNode(node) for node in nodelist_comma.split(', ')]\n\nfor node in nodelist:\n labelvalue = node\['label'].getValue()\n if not labelvalue:\n node\['label'].setValue('HAS \$GUI EXPRESSION')\n else:\n node\['label'].setValue('\{0\}\\nHAS \$GUI EXPRESSION'.format(labelvalue))"} | |
addUserKnob {26 ""} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment