def connect_selected_to_unlocked_viewer(i): if i == 0: item = nuke.menu('Nuke').findItem( 'Viewer/Connect to A Side/Using Input 10') else: item = nuke.menu('Nuke').findItem( 'Viewer/Connect to A Side/Using Input {}'.format(i)) # get the node try: vn = nuke.activeViewer().node() except AttributeError: # no viewer exists, use default behaviour which creaetes one item.invoke() vn = nuke.activeViewer().node() # check buffers then call the default action try: buffer_lock = vn['lock_buffer_{}'.format(i)].value() if not nuke.selectedNodes() or nuke.selectedNode().Class() == 'Viewer': # no nodes are selected or only a viewer node is selected - use default behaviour item.invoke() elif (vn['lock_all_buffers'].value() or buffer_lock): # viewer is locked if not buffer_lock: message = '{} is locked.'.format(vn.name()) else: message = 'Buffer {} in {} is locked.'.format(i, vn.name()) nuke.message(message) else: # viewer is unlocked item.invoke() except NameError: __create_knobs(vn) item.invoke()
def create_keyboard_shortcuts(): """Create keyboard shotcuts.""" nuke.menu('Nodes').addCommand("Transform/Tracker4", "nuke.createNode('Tracker4')", "ctrl+alt+t", icon="Tracker.png", shortcutContext=2)
def startup(self, origin): origin.timer.stop() for obj in QApplication.topLevelWidgets(): if (obj.inherits('QMainWindow') and obj.metaObject().className() == 'Foundry::UI::DockMainWindow'): nukeQtParent = obj break else: nukeQtParent = QWidget() origin.messageParent = QWidget() origin.messageParent.setParent(nukeQtParent, Qt.Window) if platform.system() != "Windows" and self.core.useOnTop: origin.messageParent.setWindowFlags(origin.messageParent.windowFlags() ^ Qt.WindowStaysOnTopHint) nuke.menu('Nuke').addCommand( 'Prism/Save Version', origin.saveScene) nuke.menu('Nuke').addCommand( 'Prism/Save Comment', origin.saveWithComment) nuke.menu('Nuke').addCommand( 'Prism/Project Browser', origin.projectBrowser) nuke.menu('Nuke').addCommand( 'Prism/Update selected read nodes', self.updateNukeNodes) nuke.menu('Nuke').addCommand( 'Prism/Settings', origin.prismSettings) toolbar = nuke.toolbar("Nodes") iconPath = os.path.join(origin.prismRoot, "Scripts", "UserInterfacesPrism", "p_tray.png") toolbar.addMenu( 'Prism', icon=iconPath ) toolbar.addCommand( "Prism/WritePrism", lambda: nuke.createNode('WritePrism')) nuke.addOnScriptLoad(origin.sceneOpen) self.isRendering = [False,""] self.useLastVersion = False
def buildNukeMenu(self): self.NukeMenu = nuke.menu( "Nuke" ).findItem( "RG" ) if not self.NukeMenu: self.NukeMenu = nuke.menu( "Nuke" ).addMenu("RG") self._builMenuFromPath(self.NukeMenu, os.path.dirname(__file__), "NukeMenu")
def addGizmosFromAsset(asst): gizmos = False a = ueAssetUtils.getElements(ueSpec.Spec(asst[0], asst[1], asst[2])) if "giz" in a: for n in a["giz"]: for p in a["giz"][n]: spec = ueSpec.Spec(asst[0], asst[1], asst[2], "giz", n, p) versions = ueAssetUtils.getVersions(spec) version = versions[len(versions) - 1] menu = "%s:%s:%s/%s/%s" % (spec.proj, spec.grp, spec.asst, n, p) # Add a 'ueGizVers' knob to hold the version of the gizmo # we're bringing in. This can be used for version control later. # When you add a custom knob, Nuke makes the User tab active, # so a hack around that is to add the node with the prefs panel # disabled, add the custom knobs, then show the prefs. command = str('n = nuke.createNode("' + version["file_name"] + '", \ "name ' + p + '", inpanel=False); \ n.addKnob(nuke.Int_Knob("ueGizmoVers", "gizmo version")); \ n.knob("ueGizmoVers").setValue(' + str(len(versions)) + '); \ n.showControlPanel()') nuke.toolbar("Nodes").addCommand("ueTools/" + menu, command) nuke.menu("Nuke").addCommand("ueTools/gizmos/" + menu, command) gizmos = True if gizmos: nuke.toolbar("Nodes").addCommand("ueTools/-", "")
def setupGUI(): # Right-mouse Popcorn menu for knobs derived from nuke.Array_Knob nuke.menu("Animation").addCommand( "Ada/Bake This Knob", "__import__('ada.nuke.node', " "fromlist=['add_knob_to_bake']).add_knob_to_bake(nuke.thisNode(), nuke.thisKnob().name())", ) menu = nuke.menu("Nuke") menu.addCommand( "Tools/Ada/Remove Ada Tab", "__import__('ada.nuke.utils', " "fromlist=['remove_ada_tab']).remove_ada_tab(nuke.selectedNodes())", shortcut="Shift+Alt+t", ) menu.addCommand( "Tools/Ada/Bake Selected", "__import__('ada.nuke.context', " "fromlist=['Engine']).Engine.run(nodes=nuke.selectedNodes())", shortcut="Shift+b", ) menu.addCommand( "Tools/Ada/Add Knobs To Bake", "__import__('ada.nuke.node', " "fromlist=['add_knob_to_bake']).add_knob_to_bake(nuke.selectedNode())", shortcut="Shift+t", )
def addGizmoMenuItems(self, rootMenu=None, defaultTopMenu=None): ''' Recursively creates menu items for gizmos found on this instance's search paths. This only has an effect if Nuke is in GUI mode. 'rootMenu': The root Nuke menu to which the menus and menu items should be added, either as a ``nuke.Menu`` object or a string. If omitted, the Nuke 'Nodes' menu will be used. 'defaultTopMenu': If you do not wish to create new menu items at the top level of the target parent menu, directories for which top-level menus do not already exist will be added to this menu instead. This must be the name of an existing menu. ''' if not nuke.GUI: return if not self._crawlData: self.addGizmoPaths() if rootMenu is None: rootMenu = nuke.menu('Nodes') elif isinstance(rootMenu, basestring): rootMenu = nuke.menu(rootMenu) self._recursiveAddGizmoMenuItems(rootMenu, self._crawlData, defaultSubMenu=defaultTopMenu, topLevel=True)
def buildNukeMenu(self): self.NukeMenu = nuke.menu("Nuke").findItem("RG") if not self.NukeMenu: self.NukeMenu = nuke.menu("Nuke").addMenu("RG") self._builMenuFromPath(self.NukeMenu, os.path.dirname(__file__), "NukeMenu")
def add_node_menu(): """ Adds a menu item to the Node Menu. """ nuke.menu('Nodes').addCommand('Py', IMPORT_CMD, shortcut='\\', icon=ICON_PATH)
def __override_nuke_shortcuts(self, engine, nuke): """ Override various shortcut keys in Nuke to run our own commands instead :param engine: The current engine :param nuke: nuke module """ # remove default hotkey from File > Save New Comp Version... file_menu = nuke.menu("Nuke").findItem("File") save_as_item = file_menu.findItem("Save New Comp Version") save_as_item.setShortcut("") engine.log_debug("removed default hot key for File > Save Comp As...") # add new hot key for Shotgun > Shotgun Save As... sg_menu = nuke.menu("Nuke").findItem("Shotgun") if sg_menu: sg_save_as_item = sg_menu.findItem("File Save...") if sg_save_as_item: sg_save_as_item.setShortcut("Alt+Shift+S") engine.log_debug("Set hot key for SG Save...") else: sg_save_as_item = sg_menu.findItem( "Shotgun Workfiles").findItem("File Save...") if sg_save_as_item: sg_save_as_item.setShortcut("Ctrl+Shift+S") engine.log_debug("Set hot key for SG Save Comp As...") # remove default hotkey form File > Open Comp... open_item = file_menu.findItem("Open Comp...") open_item.setShortcut("") engine.log_debug("removed default hot key for File > Open...") # add new hot key for Shotgun > Shotgun Open... if sg_menu: sg_open_item = sg_menu.findItem("File Open...") if sg_open_item: sg_open_item.setShortcut("Ctrl+O") engine.log_debug("Set hot key for SG Open Comp...") else: sg_open_item = sg_menu.findItem("Shotgun Workfiles").findItem( "File Open...") if sg_opem_item: sg_open_item.setShortcut("Ctrl+O") engine.log_debug("Set hot key for SG File Open...") # remove default hotkey for write node read_node_item = nuke.menu('Nodes').findItem("Image/Read") read_node_item.setShortcut("") engine.log_debug("removed default hot key for node Image/Read...") # add new hot key for Shotgun Load if sg_menu: sg_load_item = sg_menu.findItem("Load...") if sg_load_item: sg_load_item.setShortcut("R") engine.log_debug("Set hot key for SG Load...")
def buildNodeMenu(self): # set up menu self.NodeMenu = nuke.menu( "Nodes" ).findItem( "RocketGunNodes" ) if not self.NodeMenu: self.NodeMenu = nuke.menu( "Nodes" ).addMenu("RocketGunNodes", icon="sojus.png") #autMenu self._builMenuFromPath(self.NodeMenu, os.path.dirname(__file__), "NodeMenu")
def loadGizmos(loadArr): loadArr=loadArr # gizmos toolbar = nuke.menu('Nodes') #gizmosFolder laden gizmosFolder = [] gizmoDirsArr = os.listdir(gizmosPath) for i in loadArr: gizmosFolder.append(i) for i in gizmosFolder: #does gizmogroup exist? if os.path.isdir(gizmosPath + i): #add to nodes toolbar iconsPath = gizmosPath + i + "/icons/" nuke.pluginAddPath(home+"/gizmos/"+i) nuke.pluginAddPath(home+"/gizmos/"+i+"/gizmos") nuke.pluginAddPath(home+"/gizmos/"+i+"/icons") gizmoGroup = nuke.menu('Nodes').addMenu('%s'% i, icon='%s' % ((i+".png"))) #load all gizmos in arr gizmosArr = [] gizmosPathCont = [] currentGizmoGroupPath = gizmosPath + i + "/gizmos" currentGizmoGroupIconPath = gizmosPath + i + "/icons" #does gizmos folder in group exist? if os.path.isdir(currentGizmoGroupPath): gizmosPathCont=os.listdir(currentGizmoGroupPath) for i in gizmosPathCont: if ".gizmo" in i: gizmosArr.append(i) for i in gizmosArr: gIcon=i.replace("gizmo", "png") gName=i.replace(".gizmo","") gizmoGroup.addCommand('%s'% gName, "nuke.createNode('%s')"% i, icon='%s'% gIcon); else: #nuke.message("Could not find the gizmos folder in the group \"%s\"" %i+". Please make sure that it exists.") #create folder on the fly createFolders(currentGizmoGroupPath) #does icons folder in group exist? if not os.path.isdir(currentGizmoGroupIconPath): #nuke.message("Could not find the icons folder in the group \"%s\"" %i+". Please make sure that it exists.") #create folders on the fly createFolders(currentGizmoGroupIconPath) else: nuke.message("Could not load the gizmo group \"%s\"" %i+" because it was not found. Please make sure that it exists.")
def creator_menu(): p = nuke.Panel('New Menu Item') menu_types = 'Nuke Pane Nodes Properties Animation Viewer' p.addEnumerationPulldown('menu', menu_types) p.addSingleLineInput('name', 'File/Example Item') p.addSingleLineInput('function', r'myfunction()') p.addSingleLineInput('shortcut', 'shift+a') p.show() nuke.menu(p.value('menu')).addCommand(p.value('name'), p.value('function'), p.value('shortcut'))
def startup(self, origin): origin.timer.stop() for obj in qApp.topLevelWidgets(): if (obj.inherits('QMainWindow') and obj.metaObject().className() == 'Foundry::UI::DockMainWindow'): nukeQtParent = obj break else: nukeQtParent = QWidget() origin.messageParent = QWidget() origin.messageParent.setParent(nukeQtParent, Qt.Window) origin.messageParent.setWindowFlags(origin.messageParent.windowFlags() ^ Qt.WindowStaysOnTopHint) #>>>Custom menu START nuke.menu('Nuke').addCommand( 'Prism/Project Browser', origin.projectBrowser, 'Ctrl+o', icon="F_explorer.png") nuke.menu('Nuke').addCommand( 'Prism/Save New Version', origin.saveScene, 'Alt+Shift+s') #nuke.menu('Nuke').addCommand( 'Prism/Save Comment', origin.saveWithComment) nuke.menu('Nuke').addCommand( 'Prism/Version to Latest (Reads)', self.updateNukeNodes, 'Alt+Shift+up') prismSlashMenu = nuke.menu('Nuke').addCommand( 'Prism/--------------------------------------------------') nuke.menu('Nuke').addCommand( 'Prism/Prism Settings', origin.prismSettings, icon="F_deeptopos.png") #<<<Custom menu END nuke.addOnScriptLoad(origin.sceneOpen) self.isRendering = [False,""] self.useLastVersion = False
def register_viewer_locks(): # menu entries dagContext = 2 m = nuke.menu('Nuke') hm = m.addMenu('hiddenMenu') hm.setVisible(False) for i in xrange(10): if i == 0: hm.addCommand( "Using Input 10", "lock_viewer_pipes.connect_selected_to_unlocked_viewer(0)", "0", shortcutContext=dagContext) else: hm.addCommand( "Using Input {}".format(i), "lock_viewer_pipes.connect_selected_to_unlocked_viewer({})". format(i), str(i), shortcutContext=dagContext) nuke.menu('Viewer').addCommand( "lock/current buffer", "lock_viewer_pipes.lock_buffers('current', True)") nuke.menu('Viewer').addCommand( "lock/all buffers", "lock_viewer_pipes.lock_buffers('all', True)") nuke.menu('Viewer').addCommand( "unlock/current buffer", "lock_viewer_pipes.lock_buffers('current', False)") nuke.menu('Viewer').addCommand( "unlock/all buffers", "lock_viewer_pipes.lock_buffers('all', False)")
def __init__(self, on_create=None, parent=None, winflags=None): super(TabTabTabWidget, self).__init__(parent=parent) if winflags is not None: self.setWindowFlags(winflags) self.setMinimumSize(200, 300) self.setMaximumSize(200, 300) # Store callback self.cb_on_create = on_create # Input box self.input = TabyLineEdit() # Node weighting self.weights = NodeWeights( os.path.expanduser("~/.nuke/tabtabtab_weights.json")) self.weights.load() # weights.save() called in close method import nuke nodes = find_menu_items(nuke.menu("Nodes")) + find_menu_items( nuke.menu("Nuke")) # List of stuff, and associated model self.things_model = NodeModel(nodes, weights=self.weights) self.things = QtGui.QListView() self.things.setModel(self.things_model) # Add input and items to layout layout = QtGui.QVBoxLayout() layout.addWidget(self.input) layout.addWidget(self.things) # Remove margins layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) # Update on text change self.input.textChanged.connect(self.update) # Reset selection on text change self.input.textChanged.connect( lambda: self.move_selection(where="first")) self.move_selection(where="first") # Set initial selection # Create node when enter/tab is pressed, or item is clicked self.input.returnPressed.connect(self.create) self.things.clicked.connect(self.create) # When esc pressed, close self.input.cancelled.connect(self.close) # Up and down arrow handling self.input.pressed_arrow.connect(self.move_selection)
def buildNodeMenu(self): # set up menu self.NodeMenu = nuke.menu("Nodes").findItem("RocketGunNodes") if not self.NodeMenu: self.NodeMenu = nuke.menu("Nodes").addMenu("RocketGunNodes", icon="sojus.png") #autMenu self._builMenuFromPath(self.NodeMenu, os.path.dirname(__file__), "NodeMenu")
def nuke_setup(): """Call this from menu.py to setup stuff """ # Load saved shortcuts once Nuke has started up (i.e when it has # created the Root node - otherwise some menu items might be # created after this function runs) nuke.addOnCreate(lambda: load_shortcuts(), nodeClass="Root") # Menu item to open shortcut editor nuke.menu("Nuke").addCommand("Edit/Edit keyboard shortcuts", gui)
def add_commands(): nuke.menu('Nodes').addCommand( name='Image/WriteProduct', command=create_write_product_node, shortcut='w', ) nuke.menu('Nodes').addCommand( name='Image/ReadSub', command=create_read_sub_node, )
def setUpMenus(): #Set up base menu for scripts and nodes: toolbar = nuke.menu("Nuke") menuEdit = toolbar.findItem('Edit').items() count=0 for x in menuEdit: count=count+1 if x.name() == 'Node': menuIndex=count menuTopEdit = toolbar.addMenu('Edit/Scripts', index=menuIndex) toolSetBar = nuke.menu("Nodes").findItem('ToolSets') toolSetMenu = toolSetBar.addMenu('WebTools', index=3) nukescripts.traversePluginPaths(toolSetMenu, False, [], True)
def creator_menu(): p = nuke.Panel('New Menu Item') menu_types = 'Nuke Pane Nodes Properties Animation Viewer' p.addEnumerationPulldown('menu', menu_types) p.addSingleLineInput('name','File/Example Item') p.addSingleLineInput('function', r'myfunction()') p.addSingleLineInput('shortcut', 'shift+a') p.show() nuke.menu(p.value('menu')).addCommand( p.value('name'), p.value('function'), p.value('shortcut'))
def setUpMenus(): #Set up base menu for scripts and nodes: toolbar = nuke.menu("Nuke") menuEdit = toolbar.findItem('Edit').items() count = 0 for x in menuEdit: count = count + 1 if x.name() == 'Node': menuIndex = count menuTopEdit = toolbar.addMenu('Edit/Scripts', index=menuIndex) toolSetBar = nuke.menu("Nodes").findItem('ToolSets') toolSetMenu = toolSetBar.addMenu('WebTools', index=3) nukescripts.traversePluginPaths(toolSetMenu, False, [], True)
def __init__(self, on_create = None, parent = None, winflags = None): super(TabTabTabWidget, self).__init__(parent = parent) if winflags is not None: self.setWindowFlags(winflags) self.setMinimumSize(200, 300) self.setMaximumSize(200, 300) # Store callback self.cb_on_create = on_create # Input box self.input = TabyLineEdit() # Node weighting self.weights = NodeWeights(os.path.expanduser("~/.nuke/tabtabtab_weights.json")) self.weights.load() # weights.save() called in close method import nuke nodes = find_menu_items(nuke.menu("Nodes")) + find_menu_items(nuke.menu("Nuke")) # List of stuff, and associated model self.things_model = NodeModel(nodes, weights = self.weights) self.things = QtGui.QListView() self.things.setModel(self.things_model) # Add input and items to layout layout = QtGui.QVBoxLayout() layout.addWidget(self.input) layout.addWidget(self.things) # Remove margins layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) # Update on text change self.input.textChanged.connect(self.update) # Reset selection on text change self.input.textChanged.connect(lambda: self.move_selection(where="first")) self.move_selection(where = "first") # Set initial selection # Create node when enter/tab is pressed, or item is clicked self.input.returnPressed.connect(self.create) self.things.clicked.connect(self.create) # When esc pressed, close self.input.cancelled.connect(self.close) # Up and down arrow handling self.input.pressed_arrow.connect(self.move_selection)
def get_all_tools(): all_tools = [] for item in nuke.menu("Nodes").findItem(config.NS).items(): if item.name().isupper(): tool_menu = nuke.menu("Nodes").findItem("%s/%s" % (config.NS, item.name())) try: for tool in tool_menu.items(): all_tools.append("%s/%s" % (tool_menu.name(), tool.name())) except: continue return all_tools
def add_fitment(): import os import nuke nuke_main_menu = nuke.menu('Nuke') dayu_main_menu = nuke_main_menu.addMenu('Dayu toolkit') nuke_nodes_menu = nuke.menu('Nodes') dayu_nodes_menu = nuke_nodes_menu.addMenu('Dayu toolkit', icon=NUKE_DEFAULT_ICON) custom_path = os.environ.get('MY_CUSTOM_FITMENT', '') if not custom_path: return try: root_path = Path(custom_path) main_menu_dir = root_path.child(NUKE_MAIN_MENU_DIR) toolbar_menu_dir = root_path.child(NUKE_TOOL_BAR_DIR) views_dir = root_path.child(NUKE_VIEWS_DIR) for root_dir, root_menu in [(main_menu_dir, dayu_main_menu), (toolbar_menu_dir, dayu_nodes_menu)]: if root_dir.isdir(): root_menu.clearMenu() for find_file in root_dir.listdir(): if find_file.isdir(): for match in find_file.walk(filter=file_filter): match_file = MatchFile(match, find_file.parent) match_file.add_to_menu(root_menu) elif file_filter(find_file): match_file = MatchFile(find_file, find_file.parent) match_file.add_to_menu(root_menu) # 加载 views 下的LUT文件 if views_dir.isdir(): for lut_file in views_dir.listdir(file_filter=lut_filter): nuke.ViewerProcess.register(lut_file.stem, nuke.createNode, ("Vectorfield", 'vfield_file %s' % lut_file.replace('\\', '/'))) # 刷新按钮 refresh_command = dayu_nodes_menu.addCommand('refresh', command=add_fitment, tooltip='refresh', index=-1) refresh_command.setIcon(RELOAD_ICON) except Exception as e: traceback.print_exc() return
def run(): """Add the various keying tools to the correct menus""" keying_menu = nuke.menu('Nodes').findItem('Keyer') keying_menu.addCommand( 'SpillSuppress', 'keying.SpillSuppress()', )
def jopsBookmarkAddMenus(): toolbar = nuke.menu("Nodes") toolbar = toolbar.findItem("J_Ops") toolbar = toolbar.addMenu("Python") m = toolbar.addMenu("DAG Bookmarks") m.addCommand('JB1 (Restore Bookmark 1)', 'jopsBookmarkRestore(1)', 'shift+F7') m.addCommand('JB2 (Restore Bookmark 2)', 'jopsBookmarkRestore(2)', 'shift+F8') m.addCommand('JB3 (Restore Bookmark 3)', 'jopsBookmarkRestore(3)', 'shift+F9') m.addCommand('JB4 (Restore Bookmark 4)', 'jopsBookmarkRestore(4)', 'shift+F10') m.addCommand('JB5 (Restore Bookmark 5)', 'jopsBookmarkRestore(5)') m.addCommand('JB6 (Restore Bookmark 6)', 'jopsBookmarkRestore(6)') m.addCommand('JB7 (Restore Bookmark 7)', 'jopsBookmarkRestore(7)') m.addCommand('JB8 (Restore Bookmark 8)', 'jopsBookmarkRestore(8)') m.addCommand('JB9 (Restore Bookmark 9)', 'jopsBookmarkRestore(9)') m.addCommand('JSB1 (Store Bookmark 1)', 'jopsBookmarkSave(1)', 'alt+F7') m.addCommand('JSB2 (Store Bookmark 2)', 'jopsBookmarkSave(2)', 'alt+F8') m.addCommand('JSB3 (Store Bookmark 3)', 'jopsBookmarkSave(3)', 'alt+F9') m.addCommand('JSB4 (Store Bookmark 4)', 'jopsBookmarkSave(4)', 'alt+F10') m.addCommand('JSB5 (Store Bookmark 5)', 'jopsBookmarkSave(5)') m.addCommand('JSB6 (Store Bookmark 6)', 'jopsBookmarkSave(6)') m.addCommand('JSB7 (Store Bookmark 7)', 'jopsBookmarkSave(7)') m.addCommand('JSB8 (Store Bookmark 8)', 'jopsBookmarkSave(8)') m.addCommand('JSB9 (Store Bookmark 9)', 'jopsBookmarkSave(9)') m.addCommand('JSNB1 (Store Node Bookmark 1)', 'jopsBookmarkSave(1, "node")', 'alt+shift+F7') m.addCommand('JSNB2 (Store Node Bookmark 2)', 'jopsBookmarkSave(2, "node")', 'alt+shift+F8') m.addCommand('JSNB3 (Store Node Bookmark 3)', 'jopsBookmarkSave(3, "node")', 'alt+shift+F9') m.addCommand('JSNB4 (Store Node Bookmark 4)', 'jopsBookmarkSave(4, "node")', 'alt+shift+F10') m.addCommand('JSNB5 (Store Node Bookmark 5)', 'jopsBookmarkSave(5, "node")') m.addCommand('JSNB6 (Store Node Bookmark 6)', 'jopsBookmarkSave(6, "node")') m.addCommand('JSNB7 (Store Node Bookmark 7)', 'jopsBookmarkSave(7, "node")') m.addCommand('JSNB8 (Store Node Bookmark 8)', 'jopsBookmarkSave(8, "node")') m.addCommand('JSNB9 (Store Node Bookmark 9)', 'jopsBookmarkSave(9, "node")')
def insert_toolset(toolpath, delete=False): if not os.path.isfile(toolpath): nuke.message("The tool cannot be found") return nuke.nodePaste(toolpath) if delete: print "delete this tool", toolpath os.remove(toolpath) toolset_name = os.path.splitext(os.path.basename(toolpath))[0] nuke.menu("Nodes").findItem( "%s/%s" % (config.NS, config.TOOLS_TEMP.upper())).removeItem(toolset_name)
def create_gizmos_menu(): """Create the custom gizmos menu.""" gizmos_menu = nuke.menu("Nodes").addMenu("myGizmos", icon="myGizmos_icon.png") gizmos_menu.addCommand("bm_CameraShake", "nuke.createNode('bm_CameraShake')", icon="bm_CameraShake_icon.png")
def run(): """Add animatedSnap3D menu items under the Axis Menu""" try: axis_menu = nuke.menu('Axis').findItem('Snap') except AttributeError: # Could not find Axis menu nuke.tprint( "Could not find 'Axis' menu to append animatedSnap3D commands. " "animatedSnap3D will not be available through menus." ) return else: if not axis_menu: # Found Axis, could not find Snap nuke.tprint( "Could not find 'Snap' item of sub-menu 'Axis' to append " "animatedSnap3D commands. animatedSnap3D will not be available " "through menus." ) return axis_menu.addSeparator() axis_menu.addCommand( 'Match animated selection position', 'animatedSnap3D.animated_snap()' ) axis_menu.addCommand( 'Match animated selection position, orientation', 'animatedSnap3D.animated_snap(["translate", "rotate"])' ) axis_menu.addCommand( 'Match animated selection position, orientation, size', 'animatedSnap3D.animated_snap(["translate", "rotate", "scaling"])' )
def setup_cryptomatte_ui(): if nuke.GUI: toolbar = nuke.menu("Nodes") automatte_menu = toolbar.addMenu("Cryptomatte", "cryptomatte_logo.png",index=-1) automatte_menu.addCommand("Cryptomatte", "import cryptomatte_utilities as cu; cu.cryptomatte_create_gizmo();") automatte_menu.addCommand("Decryptomatte All", "import cryptomatte_utilities as cu; cu.decryptomatte_all();") automatte_menu.addCommand("Decryptomatte Selection", "import cryptomatte_utilities as cu; cu.decryptomatte_selected();")
def tri_project_init(): nuke.tprint("*START project setup") # add new Write menu shortcut nuke.menu('Nodes').findItem('Image').addCommand("TriWrite", "nuke.createNode(\"TriWrite\")", "", icon="Write.png") if os.getenv('TRI_PROJECT_PATH') is None or os.getenv('TRI_PROJECT_ID') is None: nuke.tprint(" NO project env") return # else: # nuke.tprint(" INIT", os.getenv('TRI_PROJECT_PATH')) if 'tri_project_id' in nuke.root().knobs(): tri_update_setup() else: tri_new_setup()
def menu_setup(): """ As some of these commands are overrides for standard nuke menu items, a small line of code is required in menu.py: gear.menu_setup() This is necessary to override existing commands. """ toolbar_menu = nuke.menu('Nuke') nodes_menu = nuke.menu('Nodes') # New Menu items toolbar_menu.addCommand('File/Open Explorer Window','gear.open_explorer()','ctrl+alt+o') toolbar_menu.addCommand('Create/Create New Menu Item','gear.creator_menu()') # Standard Overrides nodes_menu.addCommand('Image/Read','gear.read_from()','r') nodes_menu.addCommand('Image/Write','gear.write_from()','w')
def add_shortcuts_from_presets(): menubar = nuke.menu("Nuke") nuke_presets = get_current_project_settings()["nuke"]["general"] if nuke_presets.get("menu"): menu_label_mapping = { "manage": "Manage...", "create": "Create...", "load": "Load...", "build_workfile": "Build Workfile", "publish": "Publish..." } for command_name, shortcut_str in nuke_presets.get("menu").items(): log.info("menu_name `{}` | menu_label `{}`".format( command_name, menu_label)) log.info("Adding Shortcut `{}` to `{}`".format( shortcut_str, command_name)) try: menu = menubar.findItem(menu_label) item_label = menu_label_mapping[command_name] menuitem = menu.findItem(item_label) menuitem.setShortcut(shortcut_str) except AttributeError as e: log.error(e)
def __create_tank_error_menu(): """ Creates a std "error" tank menu and grabs the current context. Make sure that this is called from inside an except clause. """ (exc_type, exc_value, exc_traceback) = sys.exc_info() message = "" message += "SG encountered a problem starting the Engine. " message += "Please contact us via %s\n\n" % sgtk.support_url message += "Exception: %s - %s\n" % (exc_type, exc_value) message += "Traceback (most recent call last):\n" message += "\n".join(traceback.format_tb(exc_traceback)) if nuke.env.get("gui"): nuke_menu = nuke.menu("Nuke") sg_menu = nuke_menu.addMenu("Shotgun") sg_menu.clearMenu() def cmd(m=message): nuke.message(m) sg_menu.addCommand("[SG Error - Click for details]", cmd) else: msg = "The SG Pipeline Toolkit caught an error: %s" % message logger.error(msg) nuke.error(msg)
def _install_menu(): from ..tools import (creator, publish, workfiles, loader, sceneinventory, contextmanager) # Create menu menubar = nuke.menu("Nuke") menu = menubar.addMenu(api.Session["AVALON_LABEL"]) label = "{0}, {1}".format(api.Session["AVALON_ASSET"], api.Session["AVALON_TASK"]) context_menu = menu.addMenu(label) context_menu.addCommand( "Set Context", lambda: contextmanager.show(parent=get_main_window())) menu.addSeparator() menu.addCommand("Create...", lambda: creator.show(parent=get_main_window())) menu.addCommand( "Load...", lambda: loader.show(parent=get_main_window(), use_context=True)) menu.addCommand("Publish...", lambda: publish.show(parent=get_main_window())) menu.addCommand("Manage...", lambda: sceneinventory.show(parent=get_main_window())) menu.addSeparator() menu.addCommand( "Work Files...", lambda: workfiles.show(os.environ["AVALON_WORKDIR"], parent=get_main_window())) menu.addSeparator() menu.addCommand("Reset Frame Range", reset_frame_range) menu.addCommand("Reset Resolution", reset_resolution) menu.addSeparator() menu.addCommand("Reload Pipeline", reload_pipeline)
def register(widget, name, widget_id, create=False): """registerWidgetAsPanel(widget, name, id, create) -> PythonPanel Wraps and registers a widget to be used in a Nuke panel. widget - should be a string of the class for the widget name - is is the name as it will appear on the Pane menu widget_id - should the the unique ID for this widget panel create - if this is set to true a new NukePanel will be returned that wraps this widget """ class _Panel(PythonPanel): def __init__(self, widget, name, widget_id): name_e = get_encoded(name, 'utf-8') super(_Panel, self).__init__(name_e, widget_id) self.custom_knob = nuke.PyCustom_Knob( name_e, "", "__import__('nukescripts').panels.WidgetKnob(" "__import__('{0.__module__}', globals(), locals(), ['{0.__name__}'])" ".{0.__name__})".format(widget)) self.addKnob(self.custom_knob) def _add(): return _Panel(widget, name, widget_id).addToPane() menu = nuke.menu('Pane') menu.addCommand(get_encoded(name, 'utf-8'), _add) nukescripts.registerPanel(widget_id, _add) if create: return _Panel(widget, name, widget_id)
def install(): import nuke import nukescripts.panels nukescripts.panels._kabaret_studio_widget = KabaretPanel pane_name = 'Kabaret Studio' pane_id = 'com.supamonks.kabaret.studio' class Panel(nukescripts.panels.PythonPanel): def __init__(self): super(Panel, self).__init__(pane_name, pane_id) self.customKnob = nuke.PyCustom_Knob( pane_name, '', '__import__("nukescripts").panels.WidgetKnob(' '__import__("nukescripts").panels._kabaret_studio_widget' ')') self.addKnob(self.customKnob) addPanel = lambda: Panel().addToPane() menu = nuke.menu('Pane') menu.addCommand(pane_name, addPanel) nukescripts.panels.registerPanel(pane_id, addPanel) pane = nuke.getPaneFor('DAG.1') Panel().addToPane(pane)
def create_menu_by_dir(parent, dir_): """Create menus by given folder structrue.""" if not os.path.isdir(dir_): return False _dir = os.path.abspath(dir_) def _order(name): return ('_0_' if os.path.isdir(os.path.join(_dir, name)) else '_1_') + name _listdir = sorted(os.listdir(_dir), key=_order) for i in _listdir: if i in ['icons', 'Obsolete']: continue _abspath = os.path.join(_dir, i) if os.path.isdir(_abspath): m = nuke.menu('Nodes').findItem(i) or parent.addMenu( i, icon='{}.png'.format(i)) create_menu_by_dir(m, _abspath) else: _name, _ext = os.path.splitext(i) if _ext.lower() == '.gizmo': parent.addCommand(_name, lambda name=_name: nuke.createNode(name), icon='{}.png'.format(_name))
def update_menu(self): """ Updating the global menu... """ m = nuke.menu('Nodes').addMenu('Copy Paste', icon=ICON) m.clearMenu() m.addCommand('Copy', CALL_FUNCTION + 'save_nodes()', 'shift+alt+c') p = m.addMenu('Paste') m.addSeparator() m.addCommand('Quick Paste', CALL_FUNCTION + 'quick_paste_nodes()', 'shift+alt+v') m.addSeparator() s = m.addMenu('Settings') s.addCommand('Refresh', CALL_FUNCTION + 'refresh()') s.addCommand('Clear', CALL_FUNCTION + 'clear()', tooltip=TOOLTIP_CLEAR) s.addCommand('Reset', CALL_FUNCTION + 'set_environment()', tooltip=TOOLTIP_RESET) global_copy_users = [ user.replace('.nk', '') for user in scandir.listdir(SAVED_SCRIPT_DIR) if user.endswith('.nk') ] for name in sorted(global_copy_users): cmd = CALL_FUNCTION + 'paste_nodes("{}")'.format(name) p.addCommand(name, cmd) return 1
def on_create(menupath): try: import nuke m = nuke.menu("Nodes") mitem = m.findItem(menupath) mitem.invoke() except ImportError: print "creating %s" % menupath
def gizmoMenuItems(gizmosPath): #add gizmosPath nuke.pluginAddPath(gizmosPath) #adding menu items menubar = nuke.menu("Nuke") #removing existing menu if menubar.findItem('Tapp/Gizmos'): tappmenu=menubar.findItem('Tapp') tappmenu.removeItem('Gizmos') #building menu items for item in os.listdir(gizmosPath): name=item.split('.')[0] nuke.menu('Nuke').addCommand('Tapp/Gizmos/%s' % name,'nuke.createNode(\'%s\')' % name)
def addGizmoMenuItems(self, toolbar=None, default_top_menu=None): ''' Recursively create menu items for gizmos found on the searchPaths. Only call this if youre in nuke GUI mode! (ie, from inside menu.py) toolbar - the toolbar to which to add the menus; defaults to "Nodes" default_top_menu - if you do not wish to create new "top level" menu items, then top-level directories for which there is not already a top-level menu will be added to this menu instead (which must already exist) ''' if not self._crawlData: self.addGizmoPaths() if toolbar is None: toolbar = nuke.menu("Nodes") elif isinstance(toolbar, basestring): toolbar = nuke.menu(toolbar) #toolbar.addCommand("-", "", "") self._recursiveAddGizmoMenuItems(toolbar, self._crawlData, defaultSubMenu=default_top_menu, topLevel=True)
def __create_tank_disabled_menu(details): """ Creates a std "disabled" shotgun menu """ nuke_menu = nuke.menu("Nuke") sg_menu = nuke_menu.addMenu("Shotgun") sg_menu.clearMenu() cmd = lambda d=details: __show_tank_disabled_message(d) sg_menu.addCommand("Sgtk is disabled.", cmd)
def setup_cryptomatte(): nuke.addKnobChanged(lambda: cryptomatte_knob_changed_event( nuke.thisNode(), nuke.thisKnob()), nodeClass='Cryptomatte') if nuke.GUI: toolbar = nuke.menu("Nodes") automatte_menu = toolbar.addMenu("Cryptomatte", "cryptomatte_logo.png") automatte_menu.addCommand("Cryptomatte", "import cryptomatte_utilities as cu; cu.cryptomatte_create_gizmo();") automatte_menu.addCommand("Decryptomatte All", "import cryptomatte_utilities as cu; cu.decryptomatte_all();") automatte_menu.addCommand("Decryptomatte Selection", "import cryptomatte_utilities as cu; cu.decryptomatte_selected();")
def add_to_filemenu(): menubar = nuke.menu('Nuke') menu = menubar.menu('File') menu.addSeparator(index=8) cmd = 'import pyblish_nuke.lib;pyblish_nuke.lib.filemenu_publish()' menu.addCommand('Publish', cmd, index=9) menu.addSeparator(index=10)
def create_menu(self, name, icon_name): """ create nuke menu :param name: :param icon: :return: """ tool_bar = nuke.menu('Nodes') menu = tool_bar.addMenu(name, icon=icon_name) return menu
def add_filemenu_nuke(): import nuke menubar = nuke.menu("Nuke") menu = menubar.addMenu("Tapp") cmd = "import tapp;reload(tapp)" cmd += ";win = tapp.show()" menu.addCommand("Launch", cmd)
def addMenu(dest = nuke.menu('Nodes')): """ Add a "Blackbody" menu to the desired destination (default: Nodes) menu which allows access to the lookups in the Nuke GUI. """ bb_menu = dest.addMenu('Blackbody') bb_menu.addCommand('Yxy Lookup', "blackbody.yxy_lookup()") bb_menu.addCommand('sRGB Lookup', "blackbody.srgb_lookup()") bb_menu.addCommand('log RGB Lookup', "blackbody.logrgb_lookup()")
def refresh(): toolbar = nuke.menu('Nodes') showTemplate = toolbar.addMenu(showTemplate) showTemplate.clearMenu() # reload module showTemplate.addCommand('refresh', "execfile(os.path.join(showTemplate_path, Refresh.py'))") execfile(os.path.join(showTemplate_path, 'menu.py'))
def refresh(): toolbar = nuke.menu('Nodes') cgspread_menu = toolbar.addMenu('cgspread', os.path.join(cgspread_root_path, 'icons/icon_menu/logo.png')) cgspread_menu.clearMenu() # reload module reload(command) reload(config) cgspread_menu.addCommand('refresh', "execfile(os.path.join(cgspread_root_path,'python/ToolSet/Refresh.py'))") cgspread_menu.addCommand('-', '', '')
def fillMenuFromPath(path, menu='vfxPlumber', panel='Nodes'): """ Look recursively into path and add found plugins in the menu """ pluginList = [] plugins = [] gizmoList = [] for root, dirs, files in os.walk(path): for name in files: plugins.append(os.path.join(root, name)) for i in plugins: (root, ext) = os.path.splitext(i) if root is None or len(root) == 0: continue if ext == ".nk": pluginList.append(root) elif ext == ".gizmo": gizmoList.append(root) if pluginList: pluginList.sort() m = nuke.menu(panel) for n in pluginList: m.addCommand(menu + '/' + n.replace(path, ''), 'nuke.nodePaste("%s.nk")' % n) if gizmoList: print "Processing gizmos" gizmoList.sort() m = nuke.menu(panel) for n in gizmoList: m.addCommand(menu + '/' + n.replace(path, ''), 'nuke.createNode("%s")' % n)
def __create_tank_disabled_menu(details): """ Creates a std "disabled" shotgun menu """ if nuke.env.get("gui"): nuke_menu = nuke.menu("Nuke") sg_menu = nuke_menu.addMenu("Shotgun") sg_menu.clearMenu() cmd = lambda d=details: __show_tank_disabled_message(d) sg_menu.addCommand("Toolkit is disabled.", cmd) else: nuke.error("The Shotgun Pipeline Toolkit is disabled: %s" % details)
def enablemenus(): turnon = ["JEEVES/Save","JEEVES/Write", "JEEVES/Read"] for each in turnon: m = nuke.menu( 'Nuke' ).findItem(each) m.setEnabled( True ) m = nuke.menu( 'Nuke' ).findItem("JEEVES/Connect to Jeeves") #m.setEnabled( False ) nuke.addAutoSaveFilter( nukePipe.nukeCallbacks.onAutoSave ) nuke.addAutoSaveRestoreFilter( nukePipe.nukeCallbacks.onAutoSaveRestore ) nuke.addAutoSaveDeleteFilter( nukePipe.nukeCallbacks.onAutoSaveDelete ) nuke.addKnobChanged(nukePipe.nukeCallbacks.findChangedKnob, nodeClass='Write') nuke.addFavoriteDir('job_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'))) nuke.addFavoriteDir('script_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', 'nuke', os.getenv('SHOT'), 'scripts', jeeves_core.user)) nuke.addFavoriteDir('plates_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', 'nuke', os.getenv('SHOT'), 'plates')) nuke.addFavoriteDir('assets', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', 'assets')) nuke.addFavoriteDir('3d_renders', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', '3d', os.getenv('SHOT'), 'Render_Pictures')) nuke.addFavoriteDir('grade_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'grade')) nuke.addFavoriteDir('media_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'media_imports'))
def run(): """Adds the iconPanel panel to the Layout Menu""" pane_menu = nuke.menu('Pane') pane_menu.addCommand( 'Universal Icons', 'iconPanel.IconPanel().addToPane()', index=_get_menu_item_index(pane_menu, 'Universal Icons'), ) nukescripts.registerPanel( 'com.thorium.iconPanel', 'iconPanel.IconPanel().addToPane()' )
def add_menu(): """Add "Comp Island" submenu to "Cache" menu.""" # Build Comp Island submenu m = nuke.menu('Nuke').findItem('Cache') m.addSeparator() m_ci = m.addMenu('Comp Island') # Add Comp Island features m_ci.addCommand('Localise file paths', "comp_island.localise_path()") m_ci.addCommand('Delocalise file paths', "comp_island.delocalise()") m_ci.addCommand('Localise file proxy', "comp_island.localise_proxy_path()", proxy_kbd) m_ci.addCommand('Delocalise file proxy', "comp_island.clear_local_proxy()", deproxy_kbd) m_ci.addCommand('Help (wiki)', "nukescripts.openurl.start('http://wiki.rsp.com.au/rspwiki/index.php/User:Timothyb/Comp_Localization')")