Nuke: abstracting functions used in plugins

This commit is contained in:
Jakub Jezek 2022-05-25 16:56:46 +02:00
parent 6b90f0a2c1
commit 0b9bdbf1e6
No known key found for this signature in database
GPG key ID: 730D7C02726179A7
2 changed files with 47 additions and 1 deletions

View file

@ -707,6 +707,20 @@ def get_imageio_input_colorspace(filename):
return preset_clrsp
def get_view_process_node():
reset_selection()
ipn_orig = None
for v in nuke.allNodes(filter="Viewer"):
ipn = v['input_process_node'].getValue()
if "VIEWER_INPUT" not in ipn:
ipn_orig = nuke.toNode(ipn)
ipn_orig.setSelected(True)
if ipn_orig:
return duplicate_node(ipn_orig)
def on_script_load():
''' Callback for ffmpeg support
'''
@ -2549,6 +2563,31 @@ class DirmapCache:
return cls._sync_module
def duplicate_node(node):
reset_selection()
# select required node for duplication
node_orig = nuke.toNode(node.name())
node_orig.setSelected(True)
# copy selected to clipboard
nuke.nodeCopy("%clipboard%")
# reset selection
reset_selection()
# paste node and selection is on it only
nuke.nodePaste("%clipboard%")
# assign to variable
dupli_node = nuke.selectedNode()
# reset selection
reset_selection()
return dupli_node
def dirmap_file_name_filter(file_name):
"""Nuke callback function with single full path argument.