From 926d1c7cf56ddb52b2f28e6a30c7dff5e4b53d0f Mon Sep 17 00:00:00 2001 From: TianlunPC Date: Sat, 17 Apr 2021 15:23:15 -0700 Subject: [PATCH] reformating --- __Install/_dotNuke/init.edit.py | 24 +- __Install/_dotNuke/menu.edit.py | 25 +- _mod_Download/__init__.py | 55 +++- _mod_Download/init.py | 37 ++- _mod_Drafts/dft_KnobTransfer.py | 292 ++++++++++++++++++ _pkg_KuFunc/__init__.py | 27 +- _pkg_KuFunc/mod_HoverValue.py | 2 +- _pkg_KuFunc/mod_KuUtility.py | 284 +++++++++-------- _pkg_Studios/__init__.py | 26 +- _pkg_Studios/mod_StudioLoad.py | 85 +++-- _pkg_Studios/pkgStudio_framestore/__init__.py | 36 ++- _pkg_Studios/pkgStudio_kuhq/__init__.py | 34 +- init.py | 30 +- kplogger.py | 4 +- kputl.py | 23 +- menu.py | 4 +- menu_defaults.py | 30 +- menu_items.py | 62 +++- 18 files changed, 871 insertions(+), 209 deletions(-) create mode 100644 _mod_Drafts/dft_KnobTransfer.py diff --git a/__Install/_dotNuke/init.edit.py b/__Install/_dotNuke/init.edit.py index 5e89795..83604f8 100644 --- a/__Install/_dotNuke/init.edit.py +++ b/__Install/_dotNuke/init.edit.py @@ -8,14 +8,32 @@ -########## PLUGIN DIRECTORIES ########## +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + import os + + + +#------------------------------------------------------------------------------- +#-Functions +#------------------------------------------------------------------------------- + + + + # Set ENV Variables, to change when installed -os.environ['KU_PKG_PATH'] = "/Users/Tianlun/Documents/GitHub/_NukeStudio" -os.environ['KU_STUDIO_ENV'] = "MPC" +os.environ['KU_PKG_PATH'] = "URL/TO/PACKAGE/" +os.environ['KU_STUDIO_ENV'] = "STUDIONAME" + +print("\n") +print("Comfirm Package location: %s" % os.getenv('KU_PKG_PATH')) +print("\n") # Install Package nuke.pluginAddPath(os.getenv('KU_PKG_PATH')) diff --git a/__Install/_dotNuke/menu.edit.py b/__Install/_dotNuke/menu.edit.py index 7a671b4..957d1e7 100644 --- a/__Install/_dotNuke/menu.edit.py +++ b/__Install/_dotNuke/menu.edit.py @@ -7,8 +7,27 @@ + +#------------------------------------------------------------------------------- +#-Module Imort +#------------------------------------------------------------------------------- + + + + import os -print "\n" -print "Comfirm Package location: %s" % os.getenv('KU_PKG_PATH') -print "\n" + + + + +#------------------------------------------------------------------------------- +#-Confirming +#------------------------------------------------------------------------------- + + + + +print("\n") +print("Load menu.py") +print("\n") diff --git a/_mod_Download/__init__.py b/_mod_Download/__init__.py index 6f39498..86a3d66 100644 --- a/_mod_Download/__init__.py +++ b/_mod_Download/__init__.py @@ -1,8 +1,59 @@ -__all__ = [ +''' + +Selective Modules to load from Community + +''' + + + + +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + +import os +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Selected Modules +#------------------------------------------------------------------------------- + + + + +mods = [ 'mod_autolife', 'mod_AlignNodes', 'mod_ScaleTree', 'mod_Tabtabtab', 'knob_scripter', 'mod_TurboMerge' -] \ No newline at end of file +] + +__all__ = [] + + + +#------------------------------------------------------------------------------- +#-Logging Module Contents +#------------------------------------------------------------------------------- + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) + +dir = os.path.dirname(__file__) +log.info("\033[93m\nFrom Package: %s\n\nLoad:\033[0m" % os.path.basename(dir)) + +for m in mods: + + __all__.append(m) + log.info('--- %s' % m) + +log.info("\033[32m\n...DONE\n\033[0m") \ No newline at end of file diff --git a/_mod_Download/init.py b/_mod_Download/init.py index 93e4023..9118f16 100644 --- a/_mod_Download/init.py +++ b/_mod_Download/init.py @@ -1,3 +1,35 @@ +''' + +Append plugin path from community + +''' + + + +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + +import os +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Selected Modules +#------------------------------------------------------------------------------- + + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) + +log.info("\033[93m\nInitialize plugins for nuke:\033[0m") + kuDownloadPlugInPath=[ '_icons/', 'Cryptomatte/', @@ -7,4 +39,7 @@ for p in kuDownloadPlugInPath: nuke.pluginAddPath(p) - print '--- %s' % p + log.info('--- %s' % p) + +log.info("\033[32m\n...DONE\n\033[0m") + diff --git a/_mod_Drafts/dft_KnobTransfer.py b/_mod_Drafts/dft_KnobTransfer.py new file mode 100644 index 0000000..361e89d --- /dev/null +++ b/_mod_Drafts/dft_KnobTransfer.py @@ -0,0 +1,292 @@ +''' + +Transfer Knob Values from one script to another with the node of the same name + +''' + + + + +#------------------------------------------------------------------------------ +#-Module Import +#------------------------------------------------------------------------------ + + + + +import nuke, nukescripts +import platform +import os +from Qt import QtWidgets, QtGui, QtCore +import json +from kputl import joinPath +from kplogger import log, col + + + +#------------------------------------------------------------------------------ +#-Header +#------------------------------------------------------------------------------ + + + + +__VERSION__='0.0 beta' +__OS__=platform.system() +__MODNAME__= "KnobTransfer" +__AUTHOR__="Tianlun Jiang" +__WEBSITE__="jiangovfx.com" +__COPYRIGHT__="copyright (c) %s - %s" % (__AUTHOR__, __WEBSITE__) +__TITLE__=__MODNAME__ + ' v' + __VERSION__ + + +def _version_(): + ver=''' + + version 1.0 + - Transfer Knob Values from one script to another with the node of the same name + + + ''' + return ver + + + + +# ------------------------------------------------------------------------------ +# Global Variable +# ------------------------------------------------------------------------------ + + + +# Environment Variable for Show and Shot +ENV_SHOW = os.getenv('KP_SHOW', 'SHOW') +ENV_SHOT = os.getenv('KP_SHOT', 'SHOT') + +log.setLevel(10) + + + + +#------------------------------------------------------------------------------- +#-Core Class +#------------------------------------------------------------------------------- + + + + +class Core_KnobTransfer(QtWidgets.QWidget): + def __init__(self): + super(Core_KnobTransfer, self).__init__() + + # Define Widgets + self.title = QtWidgets.QLabel("%s" % (__TITLE__)) + self.env = QtWidgets.QLabel("%s:%s" % (ENV_SHOW, ENV_SHOT)) + self.btn_append_sel = QtWidgets.QPushButton("Append Selected Node") + self.btn_append_sel.setToolTip("Append selected node name and knobs value to current shot tab\n(update node if already existed)") + self.btn_update_sel = QtWidgets.QPushButton("Update Selected Nodes") + self.btn_update_sel.setToolTip("Update knobs value for selected nodes in the dag to current shot tab") + self.btn_update_all = QtWidgets.QPushButton("Update All Nodes") + self.btn_update_all.setToolTip("Update knobs value for all in the current shot tab") + self.btn_show_current_shot = QtWidgets.QPushButton("Show Current Shot") + self.btn_save = QtWidgets.QPushButton("Save") + self.btn_save.setToolTip("Save all shot tabs to file") + self.btn_reload = QtWidgets.QPushButton("Reload") + self.btn_reload.setToolTip("Reload all shot tabs from file") + self.help = QtWidgets.QPushButton(u"\uFF1F") + self.help.setStyleSheet("font-weight: bold") + self.help.setMaximumWidth(48) + + ## Define TabWidgets + self.tab_shots = KT_TabWidget() + + ## Signals and Slots + self.btn_show_current_shot.clicked.connect(self.tab_shots.show_current_shot_tab) + + # Define Layouts + self.layout_master = QtWidgets.QVBoxLayout() + self.setLayout(self.layout_master) + self.layout_header = QtWidgets.QHBoxLayout() + self.layout_nodes = QtWidgets.QHBoxLayout() + self.layout_widgetfunc = QtWidgets.QHBoxLayout() + + # Assign Widgets to Layouts + self.layout_header.addWidget(self.title) + self.layout_header.addStretch() + self.layout_header.addWidget(self.env) + self.layout_nodes.addWidget(self.btn_append_sel) + self.layout_nodes.addWidget(self.btn_update_sel) + self.layout_nodes.addWidget(self.btn_update_all) + self.layout_nodes.addWidget(self.btn_show_current_shot) + self.layout_nodes.addWidget(self.help) + self.layout_widgetfunc.addWidget(self.btn_save) + self.layout_widgetfunc.addWidget(self.btn_reload) + + self.layout_master.addLayout(self.layout_header) + self.layout_master.addWidget(divider()) + self.layout_master.addLayout(self.layout_nodes) + self.layout_master.addWidget(self.tab_shots) + self.layout_master.addLayout(self.layout_widgetfunc) + + self.setWindowTitle(__TITLE__) + self.setMaximumWidth(1000) + self.resize(200,500) + # self.setWindowFlags(QtCore.Qt.FramelessWindowHint) + + def run(self): + """Main Run function""" + self.show() + + def add_shot_tab(self, shot): + """add shot to tab widget + @shot: (str) shot name + return: (obj) Widget for newly created tab""" + + _tab = self.tab_shots + _thisTab = KT_ShotTab(shot, self.tab_shots) + _tab.addTab(_thisTab, shot) + + log.info("Tab created for shot: %s" % shot) + + return _thisTab + + + + +# ------------------------------------------------------------------------------ +# KT Widgets +# ------------------------------------------------------------------------------ + + + +class KT_TabWidget(QtWidgets.QTabWidget): + """KnobTransfer Tab Widget""" + def __init__(self): + super(KT_TabWidget, self).__init__() + + + + def get_shot_names(self): + """get names of all tabs + return: (list of str) list of shot names + """ + return [self.tabText(t) for t in range(self.count())] + + def get_shot_tabs(self): + """get tab widget of all shots + return: (dict) {'shotname': tab_obj} + """ + return dict( [self.tabText(t), self.widget(t)] for t in range(self.count()) ) + + def show_current_shot_tab(self): + """make tab of the current shot visiable""" + + for t in range(self.count()): + if self.tabText(t) == ENV_SHOT: + self.setCurrentIndex(t) + break + + +class KT_ShotTab(QtWidgets.QWidget): + """KnobTransfer Widget for Shot per tab + @shot: (str) shot name for this tab + @parent: (obj) main tab object + """ + def __init__(self, shot, parent=None): + super(KT_ShotTab, self).__init__() + + self.shot = shot + self.shotstab = parent + self.setToolTip(self.shot) + + self.instruction = QtWidgets.QLabel("Click on the buttons to set knob values") + self.group = QtWidgets.QGroupBox() + self.group.setFlat(True) + + self.layout_scroll = QtWidgets.QVBoxLayout() + self.layout_scroll.setContentsMargins(0,0,0,0) + self.group.setLayout(self.layout_scroll) + self.layout_master = QtWidgets.QVBoxLayout() + self.setLayout(self.layout_master) + + self.scroll = QtWidgets.QScrollArea() + self.scroll.setWidget(self.group) + self.scroll.setWidgetResizable(True) + # self.scroll.setFixedHeight(500) + self.scroll.setStyleSheet("QGroupBox, QScrollArea {border: 0px}") + + for w in range(15): + self.layout_scroll.addWidget(QtWidgets.QPushButton(str(w))) + + self.layout_master.addWidget(self.instruction) + self.layout_master.addWidget(self.scroll) + + def get_shot(self): + """get the name of the shot""" + return self.shot + + def get_layout(self): + """returns the layout obj that contains the widgets""" + return self.layout + + def get_nodes(self): + """returns a list of PushButton widgets inside the layout + return: (dict) {'button_names': obj} + """ + + dict_nodes = {} + + for w in self.layout.count(): + _thisWidget = self.layout.itemAt(_thisWidget) + if isinstance(_thisWidget, KT_NodeGroupButton): + dict_nodes[_thisWidget.text()] = _thisWidget + + +class KT_NodeGroupButton(QtWidgets.QPushButton): + """KnobTransfer Widget for node + @group_name: (str) name of the node group + @dict_nodes: (dict) {'node_name': "knobvalues"} + """ + def __init__(self, group_name, dict_nodes): + super(KT_NodeGroupButton, self).__init__() + + self.group_name = group_name + self.dict_nodes = dict_nodes + + self.setText(self.group_name) + + def transfer_knobvalues(self): + """Transfer knob values to the node of the same name in the script""" + + pass + + +class divider(QtWidgets.QFrame): + def __init__(self): + super(divider, self).__init__() + self.setFrameShape(QtWidgets.QFrame.HLine) + self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.setMaximumHeight(9) + + +# ------------------------------------------------------------------------------ +# Instancing +# ------------------------------------------------------------------------------ + + + + +KnobTransfer = Core_KnobTransfer() + +if log.level <= 10: + + KnobTransfer.add_shot_tab('ism0030') + KnobTransfer.add_shot_tab('ism0010') + KnobTransfer.add_shot_tab('ism0020') + + + log.debug(KnobTransfer.tab_shots.get_shot_names()) + +else: + nukescripts.panels.registerWidgetAsPanel('mod_KnobTransfer.Core_KnobTransfer', 'KnobTransfer', 'jiangvfx.com.KnobTransfer') + diff --git a/_pkg_KuFunc/__init__.py b/_pkg_KuFunc/__init__.py index 78cc93d..3f23e1e 100644 --- a/_pkg_KuFunc/__init__.py +++ b/_pkg_KuFunc/__init__.py @@ -5,10 +5,31 @@ ''' + + +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + import os +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Logging Module Contents +#------------------------------------------------------------------------------- + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) dir = os.path.dirname(__file__) -print( "\n From Package: %s\n\nInstall:" % os.path.basename(dir)) +log.info("\033[93m\nFrom Package: %s\n\nLoad:\033[0m" % os.path.basename(dir)) mods = [os.path.splitext(n)[0] for n in os.listdir(dir) if 'mod_' in n and '.pyc' not in n and 'upt_' not in n] __all__ = [] @@ -16,6 +37,6 @@ for m in mods: __all__.append(m) - print('---'), m + log.info('--- %s' % m) -print("\n...DONE\n") +log.info("\033[32m\n...DONE\n\033[0m") diff --git a/_pkg_KuFunc/mod_HoverValue.py b/_pkg_KuFunc/mod_HoverValue.py index 3bf079a..f4524b0 100644 --- a/_pkg_KuFunc/mod_HoverValue.py +++ b/_pkg_KuFunc/mod_HoverValue.py @@ -15,7 +15,7 @@ import nuke, nukescripts -import os +import os, platform import pprint from kputl import joinPath from Qt import QtWidgets, QtGui, QtCore diff --git a/_pkg_KuFunc/mod_KuUtility.py b/_pkg_KuFunc/mod_KuUtility.py index dafdc72..410b7e6 100644 --- a/_pkg_KuFunc/mod_KuUtility.py +++ b/_pkg_KuFunc/mod_KuUtility.py @@ -1,112 +1,65 @@ ''' -mod_KuFunc.py for _NukeStudio & _NukeFreelance -to used in both a VFX Studio and Freelance enviroment - -originally KuFunc.py - Contain sets of 'Light Weight' Functions, shouldn't be longer than 50 lines ''' -import nuke, os, nukescripts, sys - -########## GLOBAL KU FUNCTIONS ########## +#------------------------------------------------------------------------------ +#-Module Import +#------------------------------------------------------------------------------ -def ku_knobCh (node, knob, val): - node[knob].setValue(val) +import nuke, os, nukescripts, sys +import platform -def ku_knobVal (node, knob): - return node[knob].value() -def settingCh(knob, val): - nuke.root()[knob].setValue(val) - print "{knob} set to {value}".format(knob=knob, value=val) -def nukeColor(r,g,b,a): - return int('%02x%02x%02x%02x' % (r * 255, g * 255, b * 255, a * 255), 16) -def knobFlagClear(knob): - if knob.getFlag(nuke.STARTLINE) == True: - knob.clearFlag(nuke.STARTLINE) - else: - return knob +#------------------------------------------------------------------------------ +#-Header +#------------------------------------------------------------------------------ -########## NODE GRAPH FUNCTIONS ########## +__OS__ = platform.system() +__AUTHOR__ = "Tianlun Jiang" +__WEBSITE__ = "jiangovfx.com" +__COPYRIGHT__ = "copyright (c) %s - %s" % (__AUTHOR__, __WEBSITE__) -def mask(): - for n in nuke.selectedNodes(): - if n != 0: - mk = n.optionalInput() - n.setInput(mk, nuke.selectedNodes()[0]) +########## GLOBAL KU FUNCTIONS ########## -def reloadRead(): - #Define Functions - def reload(node,node_list): - node['reload'].execute() - node_list.append("%s Reloaded" % (node.name())) - #Define Variables - read_sel = nuke.selectedNodes('Read') - reload_list = [] - #Reloading - if len(read_sel)>0: #if there are Read node Selectred - for s in read_sel: - if s.Class() == "Read": - reload(s,reload_list) - elif len(nuke.allNodes('Read'))>0: #if there are Read Node Enabled - for e in nodes_read: - if e['disable'] == False: - reload(e,reload_list) - else: - nuke.message("No Read Nodes to Reload") - print '\n, '"="*25, '\n' - print "\n".join(reload_list) - print '\n, '"="*25, '\n' +########## NODE GRAPH FUNCTIONS ########## -def showFileDir(): - nodes = nuke.allNodes('Read') - print "========== FILES ==========", "\n\n" +def mask(): + for n in nuke.selectedNodes(): + if n != 0: + mk = n.optionalInput() + n.setInput(mk, nuke.selectedNodes()[0]) - for n in nodes: - print '------ ', n.name() , " -> ",n['file'].value(), "\n", "__________" - print "\n\n", "========== END FILES ==========" -def resetNodeCol(): - aNode = [] - - for n in nuke.allNodes(): - if n.Class() == "Grade" or n.Class() == "Merge2" or n.Class() == "Keymix": - n['tile_color'].setValue(0) - aNode.append(n.name()) - - nuke.message('Reseted Color For: ' + '\n' + str(', '.join(aNode))) - def groupConnect(): sel = nuke.selectedNodes() @@ -197,17 +150,6 @@ def selectChildNodes(): print sel.name(), " is connected by ", "\n", ', '.join(childNodes) -def selConnected(): - - for n in nuke.selectedNodes(): - n_frist = n.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS)[0] - n_second = n_first.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS)[0] - - n_first['selected'].setValue(True) - n_sec['selected'].setValue(True) - - n['selected'].setValue(False) - def quickChannel(): node = nuke.selectedNode() @@ -232,31 +174,6 @@ def quickChannel(): nuke.message("No Channel to Change") -def holdAtFrame(): - node = nuke.selectedNode() - node_label = node['label'].value() - - nukescripts.node_copypaste() # Duplicating the Node - print "\n\n", node.name() - - node_held = nuke.selectedNode() # Return the duplicated node - - for name, k in node_held.knobs().items(): - try: - if k.isAnimated(): - k.clearAnimated() - print 'Deleting Animation on %s' % name - except: - print 'no animation to delete' - - node_held['tile_color'].setValue(2147418367) # Light Green Color - - if node_label != "": # for MPC Naming convnsion - node_held['label'].setValue(node_label + "\n" + "x" + str(nuke.frame())) - else: - node_held['label'].setValue("x" + str(nuke.frame())) - - def stackIBK(): '''build IBK stack with one IBK master node selected''' @@ -329,21 +246,6 @@ def disable(): -def swapColorspace(): - '''swap in and out OCIOcolorspace node''' - nodes = nuke.selectedNodes('OCIOColorSpace') - - if nodes: - for n in nodes: - old_in = n['in_colorspace'].value() - old_out = n['out_colorspace'].value() - - n['in_colorspace'].setValue(old_out) - n['out_colorspace'].setValue(old_in) - else: - nuke.message('Select OCIOColorSpace node') - - def showIPPanel(panelfloat=True): '''Show viewer input control panel''' @@ -369,7 +271,7 @@ def copyMasterNodeStyle(): d['note_font_color'].setValue(n['note_font_color'].value()) -def add_gizmo_copyright(n): +def addGizmoCopyright(n): '''add gizmo copyright''' c_str = """ @@ -384,7 +286,7 @@ def add_gizmo_copyright(n): n.addKnob(k_copyright) -def set_viewer(mode='restore'): +def setViewer(mode='restore'): '''set and restore viewer input pipes mode='restore': restore set inputs mode='set': record exsisting inputs @@ -411,11 +313,11 @@ def set_viewer(mode='restore'): print("%s:%s" % (n[0], n[1])) -def GUISwitch(mode='switch'): +def guiSwitch(mode='switch'): ''' - - mode='switch': add $gui if none, remove if do - - mode='reverse': revserse $gui if !$gui, also add $gui if none + @mode='switch': add $gui if none, remove if do + @mode='reverse': revserse $gui if !$gui, also add $gui if none ''' nodes = nuke.selectedNodes() @@ -437,3 +339,141 @@ def setGUI(): knob.setExpression('$gui') else: knob.setExpression('!$gui') + + + + + + +#------------------------------------------------------------------------------- +#-Obsolete Functions +#------------------------------------------------------------------------------- + + + + +""" + + +def ku_knobCh (node, knob, val): + node[knob].setValue(val) + +def ku_knobVal (node, knob): + return node[knob].value() + +def settingCh(knob, val): + nuke.root()[knob].setValue(val) + print "{knob} set to {value}".format(knob=knob, value=val) + +def knobFlagClear(knob): + if knob.getFlag(nuke.STARTLINE) == True: + knob.clearFlag(nuke.STARTLINE) + else: + return knob + +def showFileDir(): + + nodes = nuke.allNodes('Read') + + print "========== FILES ==========", "\n\n" + + for n in nodes: + print '------ ', n.name() , " -> ",n['file'].value(), "\n", "__________" + + print "\n\n", "========== END FILES ==========" + + +def resetNodeCol(): + aNode = [] + + for n in nuke.allNodes(): + if n.Class() == "Grade" or n.Class() == "Merge2" or n.Class() == "Keymix": + n['tile_color'].setValue(0) + aNode.append(n.name()) + + nuke.message('Reseted Color For: ' + '\n' + str(', '.join(aNode))) + + +def reloadRead(): + + #Define Functions + def reload(node,node_list): + node['reload'].execute() + node_list.append("%s Reloaded" % (node.name())) + + #Define Variables + + read_sel = nuke.selectedNodes('Read') + reload_list = [] + + #Reloading + + if len(read_sel)>0: #if there are Read node Selectred + for s in read_sel: + if s.Class() == "Read": + reload(s,reload_list) + + elif len(nuke.allNodes('Read'))>0: #if there are Read Node Enabled + for e in nodes_read: + if e['disable'] == False: + reload(e,reload_list) + + else: + nuke.message("No Read Nodes to Reload") + + print '\n, '"="*25, '\n' + print "\n".join(reload_list) + print '\n, '"="*25, '\n' + + +def selConnected(): + + for n in nuke.selectedNodes(): + n_frist = n.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS)[0] + n_second = n_first.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS)[0] + + n_first['selected'].setValue(True) + n_sec['selected'].setValue(True) + + n['selected'].setValue(False) + + +def holdAtFrame(): + node = nuke.selectedNode() + node_label = node['label'].value() + + nukescripts.node_copypaste() # Duplicating the Node + print "\n\n", node.name() + + node_held = nuke.selectedNode() # Return the duplicated node + + for name, k in node_held.knobs().items(): + try: + if k.isAnimated(): + k.clearAnimated() + print 'Deleting Animation on %s' % name + except: + print 'no animation to delete' + + node_held['tile_color'].setValue(2147418367) # Light Green Color + + if node_label != "": # for MPC Naming convnsion + node_held['label'].setValue(node_label + "\n" + "x" + str(nuke.frame())) + else: + node_held['label'].setValue("x" + str(nuke.frame())) + + +def swapColorspace(): + '''swap in and out OCIOcolorspace node''' + nodes = nuke.selectedNodes('OCIOColorSpace') + + if nodes: + for n in nodes: + old_in = n['in_colorspace'].value() + old_out = n['out_colorspace'].value() + + n['in_colorspace'].setValue(old_out) + n['out_colorspace'].setValue(old_in) + else: + nuke.message('Select OCIOColorSpace node') +""" \ No newline at end of file diff --git a/_pkg_Studios/__init__.py b/_pkg_Studios/__init__.py index d670eb7..8e94c3d 100644 --- a/_pkg_Studios/__init__.py +++ b/_pkg_Studios/__init__.py @@ -7,11 +7,29 @@ -import nuke, os +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + +import os +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Logging Module Contents +#------------------------------------------------------------------------------- + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) + dir = os.path.dirname(__file__) -print "\n", "From Package: %s\n\nInstall:" % os.path.basename(dir) +log.info("\033[93m\nFrom Package: %s\n\nLoad:\033[0m" % os.path.basename(dir)) mods = [os.path.splitext(n)[0] for n in os.listdir(dir) if 'mod_' in n and '.pyc' not in n and 'upt_' not in n] __all__ = [] @@ -19,6 +37,6 @@ for m in mods: __all__.append(m) - print '---', m + log.info('--- %s' % m) -print "\n...DONE\n" +log.info("\033[32m\n...DONE\n\033[0m") \ No newline at end of file diff --git a/_pkg_Studios/mod_StudioLoad.py b/_pkg_Studios/mod_StudioLoad.py index ba4ab3c..96978ec 100644 --- a/_pkg_Studios/mod_StudioLoad.py +++ b/_pkg_Studios/mod_StudioLoad.py @@ -8,40 +8,63 @@ +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + import os +#------------------------------------------------------------------------------- +#-Slates +#------------------------------------------------------------------------------- + + + + +SLATE = { + 'kuhq': ['WSLENV','KP_SHOW', 'KP_SCENE', 'KP_SHOT'], + 'mpc': ['JOB', 'SCENE', 'SHOTNAME'], + 'atomic': ['JOB', 'SCENE', 'SHOTNAME'], + 'framestore': ['PL_SHOW', 'PL_SEQ', 'PL_SHOT'] +} + + + +#------------------------------------------------------------------------------- +#-Slate +#------------------------------------------------------------------------------- + + + + def LoadSlate(): - '''load slate variables per studio''' - - SLATE = { - 'kuhq': ['WSLENV','KP_SHOW', 'KP_SCENE', 'KP_SHOT'], - 'mpc': ['JOB', 'SCENE', 'SHOTNAME'], - 'atomic': ['JOB', 'SCENE', 'SHOTNAME'], - 'framestore': ['PL_SHOW', 'PL_SEQ', 'PL_SHOT'] - } - - STUDIO = os.getenv("KU_STUDIO_ENV") - - if STUDIO=='kuhq': - shell = os.getenv('KP_SHELL') - if shell=="CMD": - SHOW = os.getenv(SLATE[STUDIO][1]) - SCENE = os.getenv(SLATE[STUDIO][2]) - SHOT = os.getenv(SLATE[STUDIO][3]) - elif shell==None: - SHOW, SCENE, SHOT = 'SHOW', 'SCENE', 'SHOT' - else: - # Transfer enviroment variable from WSL to Win - SHOW, SCENE, SHOT = os.getenv(SLATE[STUDIO][0]).split(':') - else: - SHOW = os.getenv(SLATE[STUDIO][0]) - SCENE = os.getenv(SLATE[STUDIO][1]) - SHOT = os.getenv(SLATE[STUDIO][2]) - - try: - return {'SHOW': SHOW, 'SCENE': SCENE, 'SHOT': SHOT} - except: - return None + '''load slate variables per studio''' + + STUDIO = os.getenv("KU_STUDIO_ENV") + + if STUDIO=='kuhq': + shell = os.getenv('KP_SHELL') + if shell=="CMD": + SHOW = os.getenv(SLATE[STUDIO][1]) + SCENE = os.getenv(SLATE[STUDIO][2]) + SHOT = os.getenv(SLATE[STUDIO][3]) + elif shell==None: + SHOW, SCENE, SHOT = 'SHOW', 'SCENE', 'SHOT' + else: + # Transfer enviroment variable from WSL to Win + SHOW, SCENE, SHOT = os.getenv(SLATE[STUDIO][0]).split(':') + else: + SHOW = os.getenv(SLATE[STUDIO][0]) + SCENE = os.getenv(SLATE[STUDIO][1]) + SHOT = os.getenv(SLATE[STUDIO][2]) + + try: + return {'SHOW': SHOW, 'SCENE': SCENE, 'SHOT': SHOT} + except: + return None diff --git a/_pkg_Studios/pkgStudio_framestore/__init__.py b/_pkg_Studios/pkgStudio_framestore/__init__.py index 577dc88..7ebcfd0 100644 --- a/_pkg_Studios/pkgStudio_framestore/__init__.py +++ b/_pkg_Studios/pkgStudio_framestore/__init__.py @@ -1,23 +1,43 @@ ''' -__init__.py for studio_framestore # <- change to package name +__init__.py for studio_framestore ''' + + +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + import os -# Change this to package name -__STUDIO__='framestore' +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Logging Module Contents +#------------------------------------------------------------------------------- + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) dir = os.path.dirname(__file__) -print "\n", "From Package: %s\n\nInstall:" % os.path.basename(dir) +log.info("\033[93m\nFrom Package: %s\n\nLoad:\033[0m" % os.path.basename(dir)) -mods = [os.path.splitext(n)[0] for n in os.listdir(dir) if __STUDIO__ in n and '.pyc' not in n] -__all__ = ['menu'] +mods = [os.path.splitext(n)[0] for n in os.listdir(dir) if 'mod_' in n and '.pyc' not in n and 'upt_' not in n] +__all__ = [] for m in mods: __all__.append(m) - print '---', m + log.info('--- %s' % m) + +log.info("\033[32m\n...DONE\n\033[0m") -print "\n...DONE\n" diff --git a/_pkg_Studios/pkgStudio_kuhq/__init__.py b/_pkg_Studios/pkgStudio_kuhq/__init__.py index 59edb97..44d67d1 100644 --- a/_pkg_Studios/pkgStudio_kuhq/__init__.py +++ b/_pkg_Studios/pkgStudio_kuhq/__init__.py @@ -5,21 +5,39 @@ ''' -import os, nuke -# Change this to package name + + +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + +import os +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Logging Module Contents +#------------------------------------------------------------------------------- + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) dir = os.path.dirname(__file__) -print "\n", "From Package: %s\n\nInstall:" % os.path.basename(dir) +log.info("\033[93m\nFrom Package: %s\n\nLoad:\033[0m" % os.path.basename(dir)) mods = [os.path.splitext(n)[0] for n in os.listdir(dir) if 'mod_' in n and '.pyc' not in n and 'upt_' not in n] -__all__ = ['slate'] +__all__ = [] for m in mods: __all__.append(m) - print '---', m - -print "\n...DONE\n" + log.info('--- %s' % m) +log.info("\033[32m\n...DONE\n\033[0m") -nuke.pluginAddPath('pkgMod_WorkbenchManager/') diff --git a/init.py b/init.py index aca2cbe..dce39c2 100755 --- a/init.py +++ b/init.py @@ -8,13 +8,32 @@ +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + import os +from kplogger import log, col + + + + +#------------------------------------------------------------------------------- +#-Module Log +#------------------------------------------------------------------------------- + + + +log.info("\033[036m\nfile: %s\033[0m" % os.path.relpath(__file__, os.getenv('KU_PKG_PATH'))) STUDIO = os.environ['KU_STUDIO_ENV'] -print "\n\n\n==========\nStudio set to %s\n==========" % STUDIO -print "\n\n\n>>>", "Start Install %s" % (os.path.basename(os.path.dirname(__file__))), "<<<\n\n\n" +log.info("\033[44m\n\n\n>>> Studio set to %s\033[0m" % STUDIO) + +log.info("\033[44m\n\n\n>>> Start Install %s\n\n\n\033[0m" % (os.path.basename(os.path.dirname(__file__)))) kuPlugInPath=[ './_pkg_KuFunc', @@ -26,7 +45,10 @@ './_mod_Download/' ] -print "Adding kupipeline plugin path" +log.info("\033[93m\nAdding kupipeline plugin path\033[0m") + for p in kuPlugInPath: nuke.pluginAddPath(p) - print '--- %s' % p + log.info('--- %s' % p) + +log.info("\033[32m\n...CONTINUE...\n\033[0m") # Continue to init.py file in _mod_Download diff --git a/kplogger.py b/kplogger.py index 0cdb3e0..29c9a54 100644 --- a/kplogger.py +++ b/kplogger.py @@ -112,7 +112,7 @@ def bracket(col,msg): -log = logging.getLogger(__name__) +log = logging.getLogger('kplogger') loglevel = os.getenv('KPENV') if loglevel: print('==========\nlogging level: %s\n==========' % LEVEL_TO_STR[int(loglevel)]) @@ -136,7 +136,7 @@ class KuFormatter(logging.Formatter): FORMATS = { - logging.DEBUG : ''.join([col.DEBUG, "%(levelname)s", col.LINENUM, "Ln:%(lineno)d", col.MSG, "%(message)s", col.ENDLN]), + logging.DEBUG : ''.join([col.DEBUG, "%(levelname)s %(module)s", col.LINENUM, "Ln:%(lineno)d", col.MSG, "%(message)s", col.ENDLN]), logging.INFO : ''.join([col.MSG, "%(message)s", col.ENDLN]), logging.ERROR : ''.join([col.ERROR, "%(levelname)s", col.LINENUM, "Ln:%(lineno)d", col.MSG, "%(message)s", col.ENDLN]), logging.WARNING : ''.join([col.WARNING, "%(levelname)s", col.LINENUM, "Ln:%(lineno)d", col.MSG, "%(message)s", col.ENDLN]), diff --git a/kputl.py b/kputl.py index ae2b843..240b4b6 100644 --- a/kputl.py +++ b/kputl.py @@ -7,12 +7,27 @@ +#------------------------------------------------------------------------------- +#-Module Import +#------------------------------------------------------------------------------- + + + + import os import inspect import math + +#------------------------------------------------------------------------------- +#-Functions +#------------------------------------------------------------------------------- + + + + def joinPath(*paths): '''joining path to fix windows and OSX symlink to '/' uniformly''' try: @@ -24,9 +39,13 @@ def joinPath(*paths): def nukeColor(r,g,b): '''convert rgb to nuke 16 bit value + @r,g,b: (float) float rgb values 0-1 return: 8-bit ints ''' - return int('%02x%02x%02x%02x' % (r,g,b,1), 16) + return int('%02x%02x%02x%02x' % ( + r * 255, g * 255, b * 255, 0 * 255), + 16 + ) def hsv2rgb(h, s, v): @@ -52,4 +71,4 @@ def hsv2rgb(h, s, v): elif hi == 4: r, g, b = t, p, v elif hi == 5: r, g, b = v, p, q r, g, b = int(r * 255), int(g * 255), int(b * 255) - return r, g, b \ No newline at end of file + return r, g, b diff --git a/menu.py b/menu.py index 8d47b09..f50f9c1 100755 --- a/menu.py +++ b/menu.py @@ -10,7 +10,9 @@ -########## MODULE IMPORT ########## +#------------------------------------------------------------------------------- +#-Import Menus +#------------------------------------------------------------------------------- diff --git a/menu_defaults.py b/menu_defaults.py index 552425d..7f72e54 100644 --- a/menu_defaults.py +++ b/menu_defaults.py @@ -1,3 +1,18 @@ +''' + +Sets the default values for nodes + +''' + + + +#------------------------------------------------------------------------------- +#-Module Imports +#------------------------------------------------------------------------------- + + + + import nuke from _pkg_KuFunc import * from _pkg_Studios import * @@ -7,7 +22,10 @@ -########## DEFAULT NODE VALUE ########## + +#------------------------------------------------------------------------------- +#-Default Values +#------------------------------------------------------------------------------- @@ -51,14 +69,20 @@ nuke.knobDefault('Constant.color', '0.18 0.18 0.18 1.0') nuke.knobDefault('Exposure.mode', 'Stops') -### Viewer Node ### +# Viewer Nodes nuke.knobDefault('Viewer.frame_increment', '8') nuke.knobDefault('Viewer.hide_input', 'True') -########## Nuke OnStartUp ########## +#------------------------------------------------------------------------------- +#-Nuke Startup +#------------------------------------------------------------------------------- + + + + # nuke.addOnUserCreate(function, nodeClass='Class') # nuke.addOnCreate(mod_StudioENV.StudioENV, nodeClass='Root') diff --git a/menu_items.py b/menu_items.py index 16fe131..a77ba60 100644 --- a/menu_items.py +++ b/menu_items.py @@ -1,3 +1,19 @@ +''' + +Master Menu items + +''' + + + + +#------------------------------------------------------------------------------ +#-Module Import +#------------------------------------------------------------------------------ + + + + import nuke from _pkg_KuFunc import * from _pkg_Studios import * @@ -7,7 +23,25 @@ -########## AddMenuItem Func ########## + +#------------------------------------------------------------------------------ +#-Header +#------------------------------------------------------------------------------ + + + + +__OS__ = platform.system() +__AUTHOR__ = "Tianlun Jiang" +__WEBSITE__ = "jiangovfx.com" +__COPYRIGHT__ = "copyright (c) %s - %s" % (__AUTHOR__, __WEBSITE__) + + + + +#------------------------------------------------------------------------------- +#-Menu Item Functions for KuPipeline +#------------------------------------------------------------------------------- @@ -32,7 +66,9 @@ def addMenuItem(type, mu, name, mod, hotkey="", icon="", shortcutContext=1): -########## KuFunc Menubar ########## +#------------------------------------------------------------------------------- +#-KuFunc Menubar +#------------------------------------------------------------------------------- @@ -58,8 +94,8 @@ def addMenuItem(type, mu, name, mod, hotkey="", icon="", shortcutContext=1): addMenuItem('m', kuMu, 'Scale DAG', "ScaleTree()") addMenuItem('m', kuMu, 'Create IP', "IP()", hotkey="") kuMu.addSeparator() -addMenuItem('f', kuMu, '$GUI Switch/switch', "GUISwitch(mode='switch')", hotkey="shift+D") -addMenuItem('f', kuMu, '$GUI Switch/reverse', "GUISwitch(mode='reverse')", hotkey="ctrl+shift+D") +addMenuItem('f', kuMu, '$GUI Switch/switch', "guiSwitch(mode='switch')", hotkey="shift+D") +addMenuItem('f', kuMu, '$GUI Switch/reverse', "guiSwitch(mode='reverse')", hotkey="ctrl+shift+D") addMenuItem('f', kuMu, 'Connect Mask Input', "mask()", hotkey="ctrl+Y") addMenuItem('f', kuMu, 'Group Connect A', "groupConnect()", hotkey="alt+ctrl+Y") addMenuItem('f', kuMu, 'SetVal/>', "setSize(0.25)", hotkey="alt+.", shortcutContext=2) @@ -74,7 +110,9 @@ def addMenuItem(type, mu, name, mod, hotkey="", icon="", shortcutContext=1): -########## KuFunc Toolbar ########## +#------------------------------------------------------------------------------- +#-KuFunc Toolbar +#------------------------------------------------------------------------------- @@ -105,20 +143,22 @@ def addMenuItem(type, mu, name, mod, hotkey="", icon="", shortcutContext=1): - -########## Context Menus ########### - +#------------------------------------------------------------------------------- +#-Context Menus +#------------------------------------------------------------------------------- -nuke.menu('Viewer').addCommand('Viewer Restore', "mod_KuUtility.set_viewer(mode='restore')", "alt+v", index=0, shortcutContext=0) -nuke.menu('Viewer').addCommand('Viewer Set', "mod_KuUtility.set_viewer(mode='set')", index=1, shortcutContext=0) +nuke.menu('Viewer').addCommand('Viewer Restore', "mod_KuUtility.setViewer(mode='restore')", "alt+v", index=0, shortcutContext=0) +nuke.menu('Viewer').addCommand('Viewer Set', "mod_KuUtility.setViewer(mode='set')", index=1, shortcutContext=0) -########## 3rd Party Menus ########### +#------------------------------------------------------------------------------- +#-Community Module Menus +#-------------------------------------------------------------------------------