Last active
August 25, 2021 14:49
-
-
Save tokejepsen/a2ca882169c9dc194a6ee4cd82f52c7a to your computer and use it in GitHub Desktop.
Nuke: Vertical Merge
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
import nuke | |
x_separation = 110 | |
y_separation = 110 | |
selection = {} | |
for node in nuke.allNodes(): | |
if node["selected"].value(): | |
selection[node.name()] = node | |
sorted_keys = list(reversed(sorted(selection.keys()))) | |
first_node = selection[sorted_keys[0]] | |
previous_node = first_node | |
for key in sorted_keys[1:]: | |
index = sorted_keys.index(key) | |
node = selection[key] | |
y_pos = first_node.ypos() + (index * y_separation) | |
node.setXYpos(first_node.xpos(), y_pos) | |
merge_node = nuke.createNode("Merge") | |
merge_node.setXYpos(node.xpos() + x_separation, y_pos + (node.screenHeight() / 2) - (merge_node.screenHeight() / 2)) | |
merge_node.setInput(0, previous_node) | |
merge_node.setInput(1, node) | |
previous_node = merge_node |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment