def setup_cryptomatte(): nuke.addKnobChanged(lambda: cryptomatte_knob_changed_event( nuke.thisNode(), nuke.thisKnob()), nodeClass='Cryptomatte') nuke.addKnobChanged(lambda: encryptomatte_knob_changed_event( nuke.thisNode(), nuke.thisKnob()), nodeClass='Encryptomatte') nuke.addOnCreate(lambda: encryptomatte_on_create_event( nuke.thisNode(), nuke.thisKnob()), nodeClass='Encryptomatte')
def __init__ (self) : self.rvc = rvNetwork.RvCommunicator("Nuke"); self.port = 45128 self.initialized = False self.running = False self.selectedNode = None self.commands = self.LockedFifo() self.crashFlag = self.LockedFlag() self.sessionDir = "" self.syncSelection = False self.syncFrameChange = False self.syncReadChanges = False self.rvExecPath = "" self.updateFromPrefs() self.portFile = self.sessionDir + "/rv" + str(os.getpid()) self.zoomTargetNode = None log ("adding callbacks") # nuke.addUpdateUI (self.updateUI) nuke.addKnobChanged (self.knobChanged) nuke.addOnCreate (self.onCreate) nuke.addOnDestroy (self.onDestroy) nuke.addOnScriptClose (self.onScriptClose) nuke.addOnScriptLoad (self.onScriptLoad)
def restoreComplete (self) : log ("restoreComplete") nuke.addKnobChanged (self.knobChanged) nuke.addOnCreate (self.onCreate) nuke.addOnDestroy (self.onDestroy) self.allSyncUpdate()
def tank_ensure_callbacks_registered(): """ Make sure that we have callbacks tracking context state changes. """ global g_tank_callbacks_registered if not g_tank_callbacks_registered: nuke.addOnCreate(__tank_startup_node_callback) nuke.addOnScriptSave(__tank_on_save_callback) g_tank_callbacks_registered = True
def __init__(self): # Set up the user interface from Designer. self.ui = uic.loadUi( self.uipath() ) self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"), self.render) self.ui.connect(self.ui.refreshButton, QtCore.SIGNAL("clicked()"), self.refresh) nuke.addOnCreate(self.onCreateCallback) nuke.addOnDestroy(pyQtThreadCleanupCallback, nodeClass='Root') self.setdefaults() self.ui.show()
def __init__(self): # Set up the user interface from Designer. self.ui = uic.loadUi(self.uipath()) self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"), self.render) self.ui.connect(self.ui.refreshButton, QtCore.SIGNAL("clicked()"), self.refresh) nuke.addOnCreate(self.onCreateCallback) nuke.addOnDestroy(pyQtThreadCleanupCallback, nodeClass='Root') self.setdefaults() self.ui.show()
def bootstrap(self): """ Starts the bootstrap process. """ # Nuke doesn't like us starting a thread while it is still initializing. Nuke 7 is fine, so # is Nuke Studio 10. However, Nuke 10 wants us to wait. nuke.executeInMainThread or # nukescripts.utils.executeDeferred don't seem to help, so we wait for the first node to be # created. As for Nuke Studio 9? It doesn't like the asynchronous bootstrap, so we'll have # to start synchronously. if nuke.env.get("studio") and nuke.env.get("NukeVersionMajor") < 10: self._toolkit_mgr.bootstrap_engine( os.environ.get("SHOTGUN_ENGINE", "tk-nuke"), self._entity) else: nuke.addOnCreate(self._bootstrap)
def lut_init(): # Check to see if launched from a task. if "FTRACK_TASKID" not in os.environ: return # Get published LUT, either on the current task or through parents. session = ftrack_api.Session() query = "Component where version.task_id is \"{0}\"" query += " and version.asset.type.short is \"lut\"" components = session.query(query.format(os.environ["FTRACK_TASKID"])) if not components: task = session.get("Task", os.environ["FTRACK_TASKID"]) query = "Component where version.asset.type.short is \"lut\"" query += " and version.asset.parent.id is \"{0}\"" for item in reversed(task["link"][:-1]): components = session.query(query.format(item["id"])) if components: break version = 0 component = None for c in components: if c["version"]["version"] > version: component = c version = c["version"]["version"] if not component or not list(component["component_locations"]): print "{0}: Could not find any published LUTs.".format(__file__) return # Collect component data and Nuke display name. path = component["component_locations"][0]["resource_identifier"] display_name = "" for item in component["version"]["task"]["link"][:]: display_name += session.get(item["type"], item["id"])["name"] + "/" display_name += "v" + str(version).zfill(3) # Register the lut file. nuke.ViewerProcess.register(display_name, nuke.createNode, (path.replace("\\", "/"), "")) # Adding viewerprocess callback nuke.addOnCreate(modify_viewer_node, args=(display_name), nodeClass="Viewer")
def setInitialValues(self): self.nodeSelection.addItems(['All', 'Selected']) self.search.setPlaceholderText('Search') self.replace.setPlaceholderText('Replace') self.infoBox.setReadOnly(True) self.infoBox.setFont(QtGui.QFont('Consolas', 10)) self.search.textChanged.connect(self.populateInfo) self.replace.textChanged.connect(self.populateInfo) self.classLimit.currentIndexChanged.connect(self.populateInfo) nuke.addOnCreate( lambda: QtCore.QTimer.singleShot(0, self.updateClasses)) nuke.addOnDestroy( lambda: QtCore.QTimer.singleShot(0, self.updateClasses))
def bootstrap(self): """ Starts the bootstrap process. """ # Nuke doesn't like us starting a thread while it is still initializing. Nuke 7 is fine, so # is Nuke Studio 10. However, Nuke 10 wants us to wait. nuke.executeInMainThread or # nukescripts.utils.executeDeferred don't seem to help, so we wait for the first node to be # created. As for Nuke Studio 9? It doesn't like the asynchronous bootstrap, so we'll have # to start synchronously. if nuke.env.get("studio") and nuke.env.get("NukeVersionMajor") < 10: self._toolkit_mgr.bootstrap_engine( os.environ.get("SHOTGUN_ENGINE", "tk-nuke"), self._entity ) else: nuke.addOnCreate(self._bootstrap)
def install(): ''' Installing all requarements for Nuke host ''' log.info("Registering Nuke plug-ins..") pyblish.register_plugin_path(PUBLISH_PATH) avalon.register_plugin_path(avalon.Loader, LOAD_PATH) avalon.register_plugin_path(avalon.Creator, CREATE_PATH) avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH) # Register Avalon event for workfiles loading. avalon.on("workio.open_file", lib.check_inventory_versions) pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) workfile_settings = lib.WorkfileSettings() # Disable all families except for the ones we explicitly want to see family_states = ["write", "review", "nukenodes" "gizmo"] avalon.data["familiesStateDefault"] = False avalon.data["familiesStateToggled"] = family_states # Workfiles. launch_workfiles = os.environ.get("WORKFILES_STARTUP") if launch_workfiles: nuke.addOnCreate(launch_workfiles_app, nodeClass="Root") # Set context settings. nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root") nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root") menu.install()
def register_callbacks(): # nuke.addOnCreate(crop_overscan.cropOverscan, nodeClass='Crop') nuke.addOnCreate(CamProjTab.CamProjTab01, nodeClass='Camera') nuke.addOnCreate(CamProjTab.CamProjTab01, nodeClass='Camera2') nuke.addOnCreate(DIWrite.CreateWriteTab, nodeClass='Write') nuke.addBeforeRender(writeMeta.writeMeta) nuke.addAfterRender(writeMeta.delMetaNode)
nuke.knobDefault('Multiply.label', '[value value]') nuke.knobDefault('Expression.label', 'a::[value expr3]') nuke.knobDefault('Invert.channels', 'alpha') nuke.knobDefault('IBKColourV3.Size', '1') nuke.knobDefault('Shuffle.label', '[value in]') nuke.knobDefault('Roto.cliptype', 'no clip') nuke.knobDefault('Rotopaint.cliptype', 'no clip') nuke.knobDefault('Constant.channels', 'rgba') nuke.knobDefault('Constant.color', '0.18 0.18 0.18 1.0') nuke.knobDefault('Exposure.mode', 'Stops') # Viewer Nodes nuke.knobDefault('Viewer.frame_increment', '8') nuke.knobDefault('Viewer.hide_input', 'True') #------------------------------------------------------------------------------- #-Nuke Startup #------------------------------------------------------------------------------- # nuke.addOnUserCreate(function, nodeClass='Class') # nuke.addOnCreate(mod_StudioENV.StudioENV, nodeClass='Root') def viewerSetting(): for n in nuke.allNodes('Viewer'): n['frame_increment'].setValue(8) n['hide_input'].setValue(True) nuke.addOnCreate(viewerSetting, nodeClass='Root')
def _add_callbacks(self): """ Add callbacks to watch for certain events: """ nuke.addOnCreate(self._setOCIODisplayContext, nodeClass="OCIODisplay")
import nuke from setCPRef import addSetRef, setRefToCurFrame nuke.addOnCreate(addSetRef, nodeClass=('CornerPin2D')) menu = nuke.menu('Nuke') menu.addCommand('Mo_Tools/CornerPinTools/Set CP Ref frame', lambda: setRefToCurFrame(nuke.selectedNode()), 'shift+f', icon="M.jpg")
nukescripts.drop.addDropDataCallback(jopsDropHandler) #Check for preference setting, and if drop enabled add its callback/ bookmarkEnabled = False try: bookmarkEnabled = nuke.toNode('preferences')["j_ops_enable_bookmark"].getValue() except (SyntaxError, NameError): pass if bookmarkEnabled == True: jopsBookmarkAddMenus() #Adding callbacks to ensure knobs added if needed, and interpreted. #Root is done to catch the case where there are no custom prefs, #so no creation callback for it. nuke.addOnCreate(preferencesCreatedCallback, nodeClass='Preferences') nuke.addOnCreate(preferencesCreatedCallback, nodeClass='Root') import sys import nuke print 'Loading Lab Tools...' menubar = nuke.menu("Nuke") # Custom Lab Tools toolbar = nuke.toolbar("Nodes") m = toolbar.addMenu("Lab Tools", "")
def populate_ftrack(self): import nuke import legacy from nukescripts import panels from ftrack_connect_nuke.connector import Connector # Check if QtWebKit or QWebEngine is avaliable. from FnAssetAPI.ui.toolkit import is_webwidget_supported has_webwidgets = is_webwidget_supported() Connector.registerAssets() # wrappers for initializing the widgets with # the correct connector object def wrapImportAssetDialog(*args, **kwargs): from ftrack_connect.ui.widget.import_asset import FtrackImportAssetDialog return FtrackImportAssetDialog(connector=Connector()) def wrapAssetManagerDialog(*args, **kwargs): from ftrack_connect.ui.widget.asset_manager import FtrackAssetManagerDialog return FtrackAssetManagerDialog(connector=Connector()) # Populate the ui nukeMenu = nuke.menu("Nuke") ftrackMenu = nukeMenu.addMenu("&ftrack") ftrackMenu.addSeparator() # add ftrack publish node to the menu ftrackMenu.addCommand('Create Publish Node', lambda: legacy.createFtrackPublish()) ftrackMenu.addSeparator() globals()['ftrackImportAssetClass'] = wrapImportAssetDialog panels.registerWidgetAsPanel( '{0}.{1}'.format(__name__, 'ftrackImportAssetClass'), 'ftrackImportAsset', 'ftrackDialogs.ftrackImportAssetDialog') ftrackMenu.addSeparator() ftrackMenu.addCommand( 'Import Asset', 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("ftrackDialogs.ftrackImportAssetDialog");' 'panel.addToPane(pane)') globals()['ftrackAssetManagerDialogClass'] = wrapAssetManagerDialog # Create the asset manager dialog entry in the menu panels.registerWidgetAsPanel( '{0}.{1}'.format(__name__, 'ftrackAssetManagerDialogClass'), 'ftrackAssetManager', 'ftrackDialogs.ftrackAssetManagerDialog') ftrackMenu.addCommand( 'Asset Manager', 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("ftrackDialogs.ftrackAssetManagerDialog");' 'panel.addToPane(pane)') if has_webwidgets: def wrapAssetInfoDialog(*args, **kwargs): from ftrack_connect_nuke.ui.widget.info_view import AssetInfoView return AssetInfoView(bridge=self._bridge) globals()['ftrackAssetInfoDialogClass'] = wrapAssetInfoDialog # Create the crew dialog entry in the menu panels.registerWidgetAsPanel( '{0}.{1}'.format(__name__, 'ftrackAssetInfoDialogClass'), 'ftrackAssetInfo', 'ftrackDialogs.ftrackAssetInfoDialog') ftrackMenu.addCommand( 'Asset Info', 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("ftrackDialogs.ftrackAssetInfoDialog");' 'panel.addToPane(pane)') ftrackMenu.addSeparator() if has_webwidgets: from ftrack_connect_foundry.ui.info_view import WorkingTaskInfoView as _WorkingTaskInfoView from ftrack_connect_foundry.ui.tasks_view import TasksView as _TasksView # Add Web Views located in the ftrack_connect_foundry package to the # menu for easier access. for widget in [_TasksView, _WorkingTaskInfoView]: ftrackMenu.addCommand( widget.getDisplayName(), 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("{identifier}");' 'panel.addToPane(pane)'.format( identifier=widget.getIdentifier())) ftrackMenu.addSeparator() # Add new entries in the ftrack menu. ftrackMenu.addSeparator() if has_webwidgets: from ftrack_connect_nuke.ui.widget.publish_gizmo import GizmoPublisherDialog ftrackMenu.addCommand('Publish gizmo', GizmoPublisherDialog) # Add ftrack publish node toolbar = nuke.toolbar("Nodes") ftrackNodesMenu = toolbar.addMenu("ftrack", icon="ftrack_logo.png") ftrackNodesMenu.addCommand('ftrackPublish', lambda: legacy.createFtrackPublish()) # Set calbacks def asset_info_menu_switch(): '''Enable and disable asset info depending on selection.''' this_node = nuke.thisNode() # Do not continue if selection is not node. if not isinstance(this_node, nuke.Node): return try: is_ftrack = this_node.knob('assetVersionId') except ValueError: is_ftrack = False nuke_menu = nuke.menu('Nuke') menu_item = nuke_menu.findItem('&ftrack') asset_info_menu = menu_item.findItem('Asset Info') if has_webwidgets and asset_info_menu: if is_ftrack: asset_info_menu.setEnabled(True) else: asset_info_menu.setEnabled(False) nuke.addKnobChanged(asset_info_menu_switch) # other callbacks nuke.addOnScriptLoad(legacy.refAssetManager) nuke.addOnScriptLoad(legacy.scan_for_new_assets) nuke.addOnUserCreate(legacy.addFtrackComponentField, nodeClass='Write') nuke.addOnUserCreate(legacy.addFtrackComponentField, nodeClass='WriteGeo') nuke.addOnUserCreate(legacy.addFtrackComponentField, nodeClass='Read') nuke.addKnobChanged(legacy.ftrackPublishKnobChanged, nodeClass="Group") nuke.addOnCreate(legacy.ftrackPublishHieroInit) # Set default values from environments. start_frame = os.environ.get('FS', 0) end_frame = os.environ.get('FE', 100) FnAssetAPI.logging.debug( 'Setting start frame : {}'.format(start_frame)) nuke.knob('root.first_frame', str(start_frame)) FnAssetAPI.logging.debug('Setting end frame : {}'.format(end_frame)) nuke.knob('root.last_frame', str(end_frame))
#Pr_Tools/Python/showinexplorer/memu.py, v1.0.1, 2020.01.10 import nuke import showinexplorer for node in ['Write','Read']: nuke.addOnCreate(lambda:showinexplorer.addbutton(),nodeClass=node)
def _add_root_callbacks(self): """ Add callbacks to watch for certain events: """ nuke.addOnCreate(self._setOCIOSettingsOnRootNode, nodeClass='Root')
import nuke def _cb(name): nuke.tprint(name + " " + nuke.thisNode().name()) def _cbk(name): nuke.tprint(name + " " + nuke.thisNode().name() + "." + nuke.thisKnob().name()) nuke.addOnUserCreate(_cb, ("onUserCreate")) nuke.addOnCreate(_cb, ("onCreate")) nuke.addOnScriptLoad(_cb, ("onScriptLoad")) nuke.addOnScriptSave(_cb, ("onScriptSave")) nuke.addOnScriptClose(_cb, ("onScriptClose")) nuke.addOnDestroy(_cb, ("onDestroy")) nuke.addKnobChanged(_cbk, ("knobChanged")) nuke.addUpdateUI(_cb, ("updateUI")) nuke.addAutolabel(_cb, ("autolabel"))
def moblur_controller(): # Check if the Nuke script already has a GLOBAL_MOTIONBLUR_CONTROLLER NoOp node. for x in nuke.allNodes('NoOp'): if x.name() == "GLOBAL_MOTIONBLUR_CONTROLLER": nuke.message("You already have one of those in your script!") return # Create a list to hold nodes. node_list = [] # Loop through all nodes, and the ones that have a motionblur or samples knob, add them to node_list. for n in nuke.allNodes(): if n.knob('motionblur') or n.knob('samples'): node_list.append(n) # Create a NoOp node, and set it's name. NoOp = nuke.createNode('NoOp') NoOp['name'].setValue("GLOBAL_MOTIONBLUR_CONTROLLER") # Make the node black, and the text bold. NoOp['tile_color'].setValue(255) NoOp['note_font'].setValue("Bold") # Add knobs to the NoOp node. One for motionblur samples, one for the shutter, and a third to disable all motionblur. NoOp.addKnob(nuke.Int_Knob('global_motionblur', "motionblur")) NoOp.addKnob(nuke.Double_Knob('global_shutter', "shutter")) NoOp.addKnob( nuke.Boolean_Knob('global_disable_moblur', "disable motionblur")) NoOp['global_disable_moblur'].setFlag(nuke.STARTLINE) # Set default values of out knobs NoOp['global_motionblur'].setValue(1) NoOp['global_shutter'].setValue(0.5) # Loop through all the nodes in node_list. for node in node_list: # If the node has a motionblur knob if node.knob('motionblur'): # Set an expression that links said motionblur knob to our global moblur NoOp's motionblur knob value. # There is a TCL if/else statement here saying, "If the disable_moblur knob is not checked, # set the value to the GLOBAL_MOTIONBLUR_CONTROLLER's global_motionblur knob. # Otherwise, set the value to 0." node['motionblur'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 0' ) # Same thing here -- setting an expression to link the value to the new global_shutter knob on our NoOp node. node['shutter'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter') # If the node doesn't have a motionblur knob, but it does have a samples knob, we still want to add the same expression. # The only difference here is that the samples knob is always 1 by default, so we should match that with our code. elif node.knob('samples'): node['samples'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 1' ) node['shutter'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter') # Define function to use in addOnCreate(), for when new nodes with motionblur knobs are created AFTER our NoOp node is created. # We're adding the expressions to the knobs exactly the same way we are when we create the NoOp node to begin with. def addExpr(): tn = nuke.thisNode() if tn.knob('motionblur'): tn['motionblur'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 0' ) tn['shutter'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter') elif tn.knob('samples'): tn['samples'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 1' ) tn['shutter'].setExpression( 'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter') # Any time a new node is created, the addExpr() function will run. # If a node without motionblur, samples and/or shutter knobs is created, this addOnCreate() will be ignored. nuke.addOnCreate(addExpr) # Define another function to use in nuke.addOnDestroy(), so when the NoOp node gets deleted, # all expression-links are removed and node values are set back to their defaults. def deleteExpressions(): for node in nuke.allNodes(): if node.knob('motionblur'): node['motionblur'].clearAnimated() node['motionblur'].setValue(0) node['shutter'].clearAnimated() node['shutter'].setValue(0.5) elif node.knob('samples'): node['samples'].clearAnimated() node['samples'].setValue(1) node['shutter'].clearAnimated() node['shutter'].setValue(0.5) nuke.removeOnCreate(addExpr) # Like addOnCreate, except it runs when the node is deleted. # The argument it takes is a the name of a function to run... nuke.addOnDestroy(deleteExpressions, nodeClass="NoOp")
def myTracker(): n = nuke.thisNode() int_k = nuke.Int_Knob('timeOffset_val', '') txt_k = nuke.Text_Knob('timeOffset', '') txt_k.setLabel('Time Offset') pyBtn_k = nuke.PyScript_Knob('timeOffset_btn', 'apply Time offset') pyBtn_k.clearFlag(nuke.STARTLINE) pyBtn_k.setCommand( "if(nuke.thisNode().knob('tracks').value() != 0.0):\n\tnuke.thisNode().knob('tracks').setExpression(\"curve(frame+(this.timeOffset_val)*-1)\")\nelse:\n\tnuke.message('No tracks found on this tracker node!')" ) if not n.knob(int_k.name()) and not n.knob(txt_k.name()): n.addKnob(txt_k) n.addKnob(int_k) n.knob(int_k.name()).setValue(1) n.addKnob(pyBtn_k) #'Tracker4' custom default knob values #---------------------------------------- n.knob('pretrack_filter').setValue('none') n.knob('max_error').setValue(0.1) n.knob('warp').setValue('srt') n.knob('label').setValue( "reference_frame==[format %03d [value this.knob.reference_frame]]") nuke.addOnCreate(myTracker, nodeClass="Tracker4") nuke.removeOnCreate(myTracker)
nuke.knobDefault('Defocus.label', '[value defocus]') nuke.knobDefault('Roto.cliptype', 'no clip') nuke.knobDefault('Roto.replace', 'true') nuke.knobDefault('Roto.note_font_color', '21010530') nuke.knobDefault('RotoPaint.cliptype', 'no clip') nuke.knobDefault('RotoPaint.note_font_color', '21010530') #------custom node------# toolbar = nuke.toolbar("Nodes") m = toolbar.addMenu("Jacob") n = nuke.menu("Nodes").addMenu("Other/Aliased nodes") m.addCommand("Killoutline", "nuke.createNode(\"KillOutline.nk\")") m.addCommand("Flicker", "nuke.createNode(\"Flicker\")") m.addCommand("STRamp", "nuke.createNode(\"STRamp.nk\")") m.addCommand("CameraShake_FS", "nuke.createNode(\"CameraShake.nk\")") m.addCommand("hueMix", "nuke.createNode(\"hueMix_v02.nk\")") m.addCommand("multiLevel_lightwrap", "nuke.createNode(\"multiLevel_lightwrap.nk\")") m.addCommand("Grain", "nuke.createNode(\"grain_v03.nk\")") n.addCommand('Create Custom backdrop', "mdCreateBackdrop()", 'Alt+b') from myTracker import * nuke.addOnCreate(customTracker, nodeClass="Tracker4")
else: pass nuke.addOnUserCreate(customizeNodeOnUserCreate) def uniquifyWrites(): """ Make sure Write names are not of the generic form "Write1","Write2", etc. BUG: We hook this function to addUpdateUI because customizing node name at addOnUserCreate crashes Nuke! """ n = nuke.thisNode() if re.search(r"^Write\d+$",n.name()): suffix = "".join(sample(string.ascii_letters,6)).upper() n['name'].setValue("Write_"+suffix) nuke.addOnCreate(uniquifyWrites,(),{},"Write") def writeReadingStatus(): """ Change appearance of Write nodes based on whether the node is in read/write mode. """ n = nuke.thisNode() if n['reading'].value(): n['postage_stamp'].setValue(True) n['tile_color'].setValue(13500671) elif n['reading'].value() != True and n['tile_color'].value != 0: n['postage_stamp'].setValue(False) n['tile_color'].setValue(0) else: pass
node.metadata("exr/cryptomatte/{0}/manifest".format(current_layer))) for m in manifest.keys(): if str(m).find(wildcard.rstrip("*")) != -1: if str(m) not in in_list: in_list.append(str(m)) out_list = ", ".join(in_list) node.knob("matteList").setValue(out_list) print "script by Marco Meyer" def WildCardButton(): w = nuke.Text_Knob("W", "") m = nuke.PyScript_Knob("wildCard", "Wild card", "wCard()") #t = nuke.String_Knob("WildnessLevel","Wildness Level") h = nuke.Text_Knob( "help", "Wild help", "\n\n\n1 pick one of objects you want to get with Picker\n2 Manually copy the string from 'Matte List' up to area you do not want to have\n3 press 'Wild Card' button!\n----------------------------\n\n\n Example:\nroot/human/arm/wrist/fingers/fingerA\n If you want to get all the fingers copy:\nroot/human/arm/wrist/fingers/" ) n = nuke.thisNode() try: n['W'] pass except Exception: n.addKnob(w) n.addKnob(m) #n.addKnob(t) n.addKnob(h) nuke.addOnCreate(lambda: WildCardButton(), nodeClass="Cryptomatte")
import nuke from random import randint import threading import time def addColorPickerToViewer(): n = nuke.thisNode() if "color" not in n.knobs().keys(): k = nuke.Color_Knob("color") n.addKnob(k) nuke.addOnCreate(addColorPickerToViewer, (), {}, "Viewer") def addRotoConstant(): n = nuke.thisNode() n["output"].setValue("rgba") constant = nuke.randomColorConstant() n.setInput(2, constant) last_position = None if nuke.selectedNodes(): sNode = nuke.selectedNodes()[0] n.setInput(0, sNode) last_position = (sNode.xpos(), sNode.ypos()) def afterCreate(): time.sleep(0.05) if last_position: n.setXYpos(last_position[0], last_position[1] + 80)
n = nuke.thisNode() mdTab = nuke.Tab_Knob('MetaData', 'MetaData') mdBtn = nuke.PyScript_Knob('metadata', 'Retrieve MetaData') mdDivCamera = nuke.Text_Knob('md_div_camera', 'Camera', '') mdCamera = nuke.Text_Knob('md_camera', '', ' ') mdDivExif = nuke.Text_Knob('md_div_exif', 'Exif Tags', '') mdIso = nuke.Multiline_Eval_String_Knob( 'md_iso', 'ISO', 'raw/image/iso_speed\nexif/2/ISOSpeedRatings') mdAp = nuke.Multiline_Eval_String_Knob( 'md_ap', 'Aperture', 'raw/image/aperture\ninput/fnumber\nexif/2/FNumber\nexif/2/ApertureValue' ) mdSh = nuke.Multiline_Eval_String_Knob( 'md_sh', 'Shutter', 'raw/image/shutter_speed\ninput/exposure_time\nexif/2/ExposureTime') n.addKnob(mdTab) n.addKnob(mdBtn) n.addKnob(mdDivCamera) n.addKnob(mdCamera) n.addKnob(mdDivExif) n.addKnob(mdIso) n.addKnob(mdAp) n.addKnob(mdSh) mdBtn.setValue('metaDataAction()') nuke.addOnCreate(initOFXhdrPlugin, (), nodeClass='OFXtuttleofx.hdrcalib_v1') nuke.addOnCreate(initOFXhdrPlugin, (), nodeClass='OFXtuttleofx.hdrmerge_v1')
if nuke.thisNode()['no_overwrite'].value(): file_to_be_rendered = nuke.filename(nuke.thisNode(), nuke.REPLACE) if os.path.exists(file_to_be_rendered): msg = "File already exists: %s" % file_to_be_rendered try: raise RuntimeError(msg) except RuntimeError as e: print e nuke.addBeforeFrameRender(writeNoOverwrite) def writeNoOverwriteKnob(): n = nuke.thisNode() if 'no_overwrite' not in n.knobs().keys(): n.addKnob(nuke.Boolean_Knob("no_overwrite","no_overwrite")) else: pass nuke.addOnCreate(writeNoOverwriteKnob,(),{},"Write") def setEnvironment(): """ Any knob added to a script's Root panel whose name is all capitalized is declared as an environment variable callable from any node with [getenv VARIABLE]. Note that you must reload the script before the variable becomes active. """ isAllCaps = lambda s: True if s.upper() == s else False N = [nuke.root()[i].name() for i in nuke.root().knobs() if isAllCaps(nuke.root()[i].name())] V = [nuke.root()[i].value() for i in nuke.root().knobs() if isAllCaps(nuke.root()[i].name())] h = dict(zip(N,V)) for k in h.keys(): os.environ[k] = h[k] nuke.addOnScriptLoad(setEnvironment)
'import myMerge; myMerge.mergeThis()', 'm', shortcutContext=2) nodegraphMenu.addCommand("@;MyCC", "import myCC; myCC.myCC()", "c") nuke.tprint("_" * 100) nuke.tprint("my user is loaded") nuke.tprint("_" * 100) # def example(): # import sys # from PySide2 import QtCore, QtGui, QtWidgets # pixmap = QtGui.QPixmap('/mnt/Hobby/projects/toe/07_Masters/toe.png') # label = QtWidgets.QLabel() # label.setPixmap(pixmap) # label.setScaledContents(1) # label.resize(1146/2, 1468/2) # #label.setWindowFlags(QtCore.Qt.FramelessWindowHint) # label.setAttribute(QtCore.Qt.WA_TranslucentBackground) # label.show() # nuke.addOnCreate(lambda: example() , nodeClass="Toe2") def example(): nuke.thisNode()["icon"].setValue( '/mnt/Hobby/projects/toe/07_Masters/toeST.png') nuke.addOnCreate(lambda: example(), nodeClass="Toe2")
def start(): nuke.addOnUserCreate(lambda: on_backdrop_user_created(nuke.thisNode()), nodeClass='BackdropNode') nuke.addOnCreate(lambda: on_backdrop_created(nuke.thisNode()), nodeClass='BackdropNode')
def enable(): """Enable patch. """ PatchPrecompDialog.enable() PatchPrecompSelected.enable() nuke.addOnCreate(_on_precomp_create, nodeClass='Precomp')
nuke.menu('Nuke').findItem('File').addCommand('Stop Performance Timers', 'nuke.stopPerformanceTimers()', '', index=21) nuke.menu('Nuke').findItem('File').findItem('Clear').setShortcut('ctrl+shift+w') nuke.menu('Nuke').findItem('&Cache').findItem('Clear All').setShortcut('ctrl+alt+meta+shift+w') nuke.menu('Nuke').findItem('Workspace').addCommand("Toggle Fullscreen", 'nuke.toggleFullscreen()', 'ctrl+alt+shift+f') # Show or hide Nuke statusbar nuke.menu('Nuke').addCommand('File/Show Status Bar', 'import hiero; hiero.ui.mainStatusBar.show()') nuke.menu('Nuke').addCommand('File/Hide Status Bar', 'import hiero; hiero.ui.mainStatusBar.hide()') # Default to hidden status bar # The hiero module is not available on startup, so it's not possible to do this # using a more normal approach... def hide_status_bar(): import hiero hiero.ui.mainStatusBar.hide() nuke.addOnCreate(hide_status_bar, nodeClass='Root') # Viewer Shortcuts nuke.menu('Viewer').addCommand('Next Frame', 'nuke.activeViewer().frameControl(1)', 'shift+f') nuke.menu('Viewer').addCommand('Previous Frame', 'nuke.activeViewer().frameControl(-1)', 'shift+d') nuke.menu('Viewer').addCommand('Next Keyframe', 'nuke.activeViewer().frameControl(2)', 'alt+shift+f') nuke.menu('Viewer').addCommand('Previous Keyframe', 'nuke.activeViewer().frameControl(-2)', 'alt+shift+d') nuke.menu('Viewer').addCommand('Next Frame', 'nuke.activeViewer().frameControl(1)', 'shift+f') nuke.menu('Viewer').addCommand('Play Forward', 'nuke.activeViewer().frameControl(5)', 'ctrl+alt+f') nuke.menu('Viewer').addCommand('Play Backward', 'nuke.activeViewer().frameControl(-5)', 'ctrl+alt+d') nuke.menu('Viewer').findItem('Show Overscan').setShortcut('alt+shift+o') # Nodes
nodename = nuke.thisNode().name() frame = '%s%s.%s'%('[knob ', nodename,'reference_frame]') transform['label'].setValue('%s: %s'%("reference frame",frame)) ''' value4 = ''' frame = nuke.thisNode().knob('reference_frame').value() transform['label'].setValue('%s: %s'%("reference frame",str(int(frame)))) ''' for i in knobNamelist: text = node[i].value() if knobNamelist.index(i) in [0, 1]: value = value1 elif knobNamelist.index(i) in [2, 3]: value = value2 elif knobNamelist.index(i) in [4, 5]: value = value3 elif knobNamelist.index(i) in [6, 7]: value = value4 value_text = '%s\n%s' % (text, value) node[i].setValue(value_text) nuke.addOnCreate(node_tracter, nodeClass=('Tracker4'))
# blank note node: NoOp n = nuke.createNode('NoOp') k = n.Array_Knob('knobName', 'knobLabel') k.setTooltip('this is my tooltip') n.addknob(k) # in panel node nuke.createNode('Blur', inpanel=Flase) # ----------------------------------- # session 07 # Callbacks nuke.addCallback(callable, args=(), kwargs={}, nodeClass='*') nuke.addOnCreate(nuke.message, args=('OK, you have created a write node'), nodeClass='Write') # addOnScriptLoad(...) # addKnobChanged(...) # inside python custom: nuke.thisNode().knob('knobChanged').setValue('print "Hello World!"') # or n = nuke.createNode('NoOp') n.knob('knobChanged').setValue('print "Hello World!"') # inside the python custom of a node: # there is a checkBox knob c # there is a float knob f # and a python custom kn (should not be hide) # and a pulldown knob p nuke.thisNode().knob('knobChanged').setValue("""
def _add_root_callbacks(self): """ Add callbacks to watch for certain events: """ nuke.addOnCreate(self._setOCIOSettingsOnRootNode, nodeClass='Root') nuke.addDefaultColorspaceMapper(self._nozonDefaultColorspaceMapper)
# Format format_name = slate.SHOW_CONFIG['kp_show'] + '-format' showFormat = '%s %s %s' % (slate.SHOW_CONFIG['root_format'][0], slate.SHOW_CONFIG['root_format'][1], format_name) nuke.addFormat(showFormat) root = nuke.root() root['format'].setValue(format_name) root['fps'].setValue(slate.SHOW_CONFIG['fps']) root['first_frame'].setValue(slate.SHOT_CONFIG['frameStart']) root['last_frame'].setValue(slate.SHOT_CONFIG['frameEnd']) root['lock_range'].setValue(True) root['frame'].setValue(slate.SHOT_CONFIG['frameStart']) os.environ['OCIO'] = slate.SHOW_CONFIG['colorspace'] if 'NUKE_PATH' in os.environ.keys(): os.environ['NUKE_PATH'] += ';%s' % slate.SHOW_TOOL_DIR else: os.environ['NUKE_PATH'] = slate.SHOW_TOOL_DIR print("...nuke configured") #------------------------------------------------------------------------------ #-Default startup settings root add on create #------------------------------------------------------------------------------ #ShotConfig() nuke.addOnCreate(ShotConfig, nodeClass='Root')
import nuke import addReadKnob nuke.addOnCreate(addReadKnob.add_read_knob)
def populate_ftrack(self): import nuke import legacy from nukescripts import panels from ftrack_connect_nuke.ui.widget.crew import NukeCrew from ftrack_connect_nuke.connector import Connector # Check if QtWebKit or QWebEngine is avaliable. from FnAssetAPI.ui.toolkit import is_webwidget_supported has_webwidgets = is_webwidget_supported() Connector.registerAssets() # wrappers for initializing the widgets with # the correct connector object def wrapImportAssetDialog(*args, **kwargs): from ftrack_connect.ui.widget.import_asset import FtrackImportAssetDialog return FtrackImportAssetDialog(connector=Connector()) def wrapAssetManagerDialog(*args, **kwargs): from ftrack_connect.ui.widget.asset_manager import FtrackAssetManagerDialog return FtrackAssetManagerDialog(connector=Connector()) # Populate the ui nukeMenu = nuke.menu("Nuke") ftrackMenu = nukeMenu.addMenu("&ftrack") ftrackMenu.addSeparator() # add ftrack publish node to the menu ftrackMenu.addCommand('Create Publish Node', lambda: legacy.createFtrackPublish()) ftrackMenu.addSeparator() globals()['ftrackImportAssetClass'] = wrapImportAssetDialog panels.registerWidgetAsPanel( '{0}.{1}'.format(__name__, 'ftrackImportAssetClass'), 'ftrackImportAsset', 'ftrackDialogs.ftrackImportAssetDialog') ftrackMenu.addSeparator() ftrackMenu.addCommand( 'Import Asset', 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("ftrackDialogs.ftrackImportAssetDialog");' 'panel.addToPane(pane)') globals()['ftrackAssetManagerDialogClass'] = wrapAssetManagerDialog # Create the asset manager dialog entry in the menu panels.registerWidgetAsPanel( '{0}.{1}'.format(__name__, 'ftrackAssetManagerDialogClass'), 'ftrackAssetManager', 'ftrackDialogs.ftrackAssetManagerDialog') ftrackMenu.addCommand( 'Asset Manager', 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("ftrackDialogs.ftrackAssetManagerDialog");' 'panel.addToPane(pane)') if has_webwidgets: from ftrack_connect_foundry.ui.info_view import InfoView as _InfoView ftrackMenu.addCommand( _InfoView.getDisplayName(), 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("{identifier}");' 'panel.addToPane(pane)'.format( identifier=_InfoView.getIdentifier())) ftrackMenu.addSeparator() if has_webwidgets: from ftrack_connect_foundry.ui.info_view import WorkingTaskInfoView as _WorkingTaskInfoView from ftrack_connect_foundry.ui.tasks_view import TasksView as _TasksView # Add Web Views located in the ftrack_connect_foundry package to the # menu for easier access. for widget in [_TasksView, _WorkingTaskInfoView]: ftrackMenu.addCommand( widget.getDisplayName(), 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("{identifier}");' 'panel.addToPane(pane)'.format( identifier=widget.getIdentifier())) ftrackMenu.addSeparator() # Create the crew dialog entry in the menu panels.registerWidgetAsPanel( 'ftrack_connect_nuke.ui.widget.crew.NukeCrew', 'Crew', 'widget.Crew') ftrackMenu.addCommand( 'Crew', 'pane = nuke.getPaneFor("Properties.1");' 'panel = nukescripts.restorePanel("widget.Crew");' 'panel.addToPane(pane)') # Add new entries in the ftrack menu. ftrackMenu.addSeparator() if has_webwidgets: from ftrack_connect_nuke.ui.widget.publish_gizmo import GizmoPublisherDialog ftrackMenu.addCommand('Publish gizmo', GizmoPublisherDialog) # Add ftrack publish node toolbar = nuke.toolbar("Nodes") ftrackNodesMenu = toolbar.addMenu("ftrack", icon="logobox.png") ftrackNodesMenu.addCommand('ftrackPublish', lambda: legacy.createFtrackPublish()) # Set calbacks nuke.addOnScriptLoad(legacy.refAssetManager) nuke.addOnScriptLoad(legacy.scan_for_new_assets) nuke.addOnUserCreate(legacy.addFtrackComponentField, nodeClass='Write') nuke.addOnUserCreate(legacy.addFtrackComponentField, nodeClass='WriteGeo') nuke.addOnUserCreate(legacy.addFtrackComponentField, nodeClass='Read') nuke.addKnobChanged(legacy.ftrackPublishKnobChanged, nodeClass="Group") nuke.addOnCreate(legacy.ftrackPublishHieroInit)
k = nuke.XY_Knob(n.name()) k.setValue([n.width() / 2, n.height() / 2]) tn.addKnob(k) n['p'].setExpression('parent.' + n.name()) k = nuke.PyScript_Knob('delete_' + n.name(), 'delete') tn.addKnob(k) k.clearFlag(nuke.STARTLINE) k.setCommand('\n'.join([ 'nuke.delete(nuke.thisGroup().node("' + n.name() + '"))', 'nuke.thisNode().removeKnob(nuke.thisNode()["' + n.name() + '"])', 'nuke.thisNode().removeKnob(nuke.thisKnob())' ])) nuke.addOnCreate(dg_PerspLines_OnCreate, nodeClass='dg_PerspLines') # Estimate Focal and Align Camera def dg_PerspLines_AlignCamera(): nodes = nuke.selectedNodes() if not len(nodes) == 2: nuke.message( 'Illegal amount of selected nodes.\nPlease select exactly two dg_PerspLines nodes' ) return for n in nodes: if not n.Class() == 'dg_PerspLines': nuke.message('One of selected nodes is not dg_PerspLines') return
def __initCallbacks(self): nuke.addOnCreate(self.updateNodeTree) # If a new node is created, the nodeType tableView will be updated nuke.addOnDestroy(self.updateNodeTree) # TODO: Doesn't seem to update, looks like we need to find a way to call the update AFTER the node is destroyed