def projectFavorites(): entity = ft_utils.get_entity() root = entity.getProject().getRoot() try: paths = ft_utils.getAllPathsYaml(entity) except: print 'this project is not yet supported' return if 'ASSET_BUILD' in os.environ.keys(): pathNameMapping = { 'asset.task.work': 'Task work', 'asset.render': 'Task output', } else: pathNameMapping = { 'shot.task.work': 'Task work', 'shot.render': 'Task output', } icon_path = os.path.join(os.environ['PIPELINE_IMAGES'], 'ft_logo.png') for path in paths: if path[1].name in pathNameMapping.keys(): niceName = pathNameMapping.get(path[1].name, None) nuke.removeFavoriteDir(niceName) path_to_add = os.path.join(root, path[0]) os.environ[niceName] = path_to_add nuke.addFavoriteDir(niceName, path_to_add, nuke.IMAGE | nuke.SCRIPT | nuke.GEO, icon=icon_path)
def __setup_favourite_dirs(self): """ Sets up nuke shortcut "favourite dirs" that are presented in the left hand side of nuke common dialogs (open, save) """ engine_root_dir = self.disk_location tank_logo_small = os.path.abspath(os.path.join(engine_root_dir, "resources", "logo_color_16.png")) # old versions were referring to these favourites - so keep them around to make # sure there are no old leftovers in the system... supported_entity_types = ["Shot", "Sequence", "Scene", "Asset", "Project"] for x in supported_entity_types: nuke.removeFavoriteDir("Tank Current %s" % x) #handle project proj = self.context.project paths = self.tank.paths_from_entity(proj["type"], proj["id"]) pipeline_config=tank.pipelineconfig.from_path(paths[0]) for path in paths: #getting root names if the paths are the same dirname='Unknown Path' if path in pipeline_config.get_data_roots().values(): #comparing roots paths with input path for rootname, rootpath in pipeline_config.get_data_roots().items(): if rootpath == path: dirname=rootname #removing old directory nuke.removeFavoriteDir(dirname) #adding new path nuke.addFavoriteDir(dirname, directory=path, type=(nuke.IMAGE|nuke.SCRIPT|nuke.GEO), icon=tank_logo_small, tooltip=path) #handle favourites directories for directory in self.get_setting("favorite_directories"): #removing old directory nuke.removeFavoriteDir(directory['display_name']) #getting paths from context template=self.get_template_by_name(directory['directory']) fields=self.context.as_template_fields(template) p=template.apply_fields(fields) #adding new directory nuke.addFavoriteDir(directory['display_name'], directory=p, type=(nuke.IMAGE|nuke.SCRIPT|nuke.GEO), icon=directory['icon'], tooltip=p)
def set_environment(self, config_reader, template, token_dict): # Create a favorite directory for every token in the current template token_path_dict = OrderedDict() token_list = config_reader.get_tokens(template) for token in token_list: path = os.path.join( config_reader.get_path(template, token_dict, token), token_dict[token]) self.debug_msg("Creating " + token + " path: " + path) nuke.addFavoriteDir( self.get_favorite_name(token, token_dict[token]), path)
def set_context_favorites(favorites=None): """ Addig favorite folders to nuke's browser Argumets: favorites (dict): couples of {name:path} """ favorites = favorites or {} icon_path = resources.get_resource("icons", "folder-favorite3.png") for name, path in favorites.items(): nuke.addFavoriteDir(name, path, nuke.IMAGE | nuke.SCRIPT | nuke.GEO, icon=icon_path)
def set_context_favorites(favorites={}): """ Addig favorite folders to nuke's browser Argumets: favorites (dict): couples of {name:path} """ dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) icon_path = os.path.join(dir, 'res', 'icons', 'folder-favorite3.png') for name, path in favorites.items(): nuke.addFavoriteDir(name, path, nuke.IMAGE | nuke.SCRIPT | nuke.GEO, icon=icon_path)
def onLoad(): print "launched init.py!" fps = os.environ['FPS'] width = os.environ['WIDTH'] height = os.environ['HEIGHT'] project = os.environ['PROJECT'] task = os.environ['TASK'] shot = os.environ['SHOT'] job = os.environ['JOB'] # Set Job folder in file browser nuke.addFavoriteDir( name = 'Task Dir', directory = job, type = nuke.SCRIPT) # Set res nuke.knobDefault('Root.format', width + ' ' + height + ' HD')
def setFavorites(self): # add project specific shortcuts nuke.addFavoriteDir('Desktop', 'C:/Users/' + os.environ['USERNAME'] + '/Desktop') nuke.addFavoriteDir('RB','//grey09/rugbybugs/') nuke.addFavoriteDir('RB_SHOTS', '//grey09/rugbybugs/Production/2d/comp/') nuke.addFavoriteDir('RB_RnD', self.getPersonalRndFolder()) # remove generic favorites nuke.removeFavoriteDir("Home") nuke.removeFavoriteDir("Root") nuke.removeFavoriteDir("Nuke") nuke.removeFavoriteDir("Current")
def set_workspace(self, directory): import nuke from construct_ui import resources ctx = construct.get_context() fav_icon = resources.path(':/brand/construct_icon-white-on-black') favs = ['project', 'sequence', 'shot', 'asset', 'workspace'] for fav in favs: fav_name = fav.title() nuke.removeFavoriteDir(fav_name) entry = ctx[fav] if entry: directory = entry.path nuke.addFavoriteDir(fav_name, directory=directory, type=(nuke.IMAGE | nuke.SCRIPT | nuke.GEO), icon=fav_icon, tooltip=directory) os.chdir(directory) nuke.root()['project_directory'].setValue(directory)
def loadScriptVars(): global filename global fileNameSplit global dirname global projectPath global projectName global fileVersion global isFirstLoad filename = "" fileNameSplit = [] dirname = "" projectPath = "" projectName = "" fileVersion = "" #first get metadat from filename to get project/projectname, scene number, shot Number filename = nuke.root()["name"].value() fileNameSplit = os.path.basename(filename).split("_") for path in os.listdir(readRootDir): if path.startswith(fileNameSplit[0].upper() + "_"): projectPath += readRootDir + "\\" + path dirname = fileNameSplit[0] + "_" + fileNameSplit[ 1] + "_" + fileNameSplit[2] projectName = path fileVersion = fileNameSplit[3].replace(".nk", "") print dirname print projectPath nuke.addFavoriteDir("Project", projectPath) nuke.addFavoriteDir("Inputs", projectPath + "\\input\\" + dirname + "\\") nuke.addFavoriteDir("Write", writeRootDir + "\\" + projectName + "\\" + dirname)
def guiStartup(): print 'Initializing Helix Nuke GUI...' from helix import Element, Show, Sequence, Shot, hxenv from helix.api.exceptions import EnvironmentError import helix.api.nuke.plugin as plugin import nuke helixRoot = nuke.menu('Nuke').addMenu('Helix') helixRoot.addCommand('Asset/Import...', plugin.importAsset) # File browser quick links try: element = Element.fromPk(hxenv.getEnvironment('element')) if element: nuke.addFavoriteDir(name='ASSET', directory=element.work_path) os.chdir(element.work_path) container = element.parent while not isinstance(container, Show): nuke.addFavoriteDir( name=container.__class__.__name__.upper(), directory=container.work_path) container = container.parent nuke.addFavoriteDir(name='SHOW', directory=container.work_path) print 'Done' except EnvironmentError: print 'Could not initialize Nuke for Helix without an asset' projDir = nuke.Root().knob('project_directory').value() if projDir: os.chdir(projDir)
m = nuke.menu('Animation') m.addCommand('Reduce Keyframes', "reduceKeyframes.doReduceKeyframes()") # method to add Frank Rueters Search and Replace panel def addSRPanel(): myPanel = SearchReplacePanel.SearchReplacePanel() return myPanel.addToPane() nuke.menu('Pane').addCommand('SearchReplace', addSRPanel) nukescripts.registerPanel('com.ohufx.SearchReplace', addSRPanel) ### add favourite directories nuke.addFavoriteDir('Current Script', '[file dirname [value root.name]]', nuke.IMAGE | nuke.SCRIPT, icon='script_folder.png') # call the function 'my_function' from the my_code.py file nuke.menu('Nuke').addCommand('Chetan/Lower Settings', 'my_code.lower_settings()') nuke.menu('Nuke').addCommand('Chetan/Quick 3D', 'my_code.quick_3d()', 'shift+o') nuke.menu('Nuke').addCommand('Chetan/Open Folder', 'my_code.open_main()', 'shift+o') ### add format resolutions presets - i.e.: nuke.addFormat ('1920 797 0 0 1920 797 1.0 FullHD_Widescreen') nuke.addFormat('1920 797 0 0 1920 797 1.0 FullHD_Widescreen') ### add LUT to the Root - i.e.: nuke.root().knob('luts').addCurve('nameOfTheLUT', 'formula') # sLOG formula example: '{pow(10.0, ((t - 0.616596 - 0.03) /0.432699)) - 0.037584}'
# 256 pipeline tools # INTERFACE MANIPULATIONS # Create custom menu for NUKE import nuke, os,sys import shotAssembler # Add favorite dir nuke.addFavoriteDir('COMP', '{}PROD/2D/COMP'.format(rootProject)) menubar = nuke.menu('Nuke') dna = menubar.addMenu('DNA') dna.addCommand('ASSEMBLER',shotAssembler.assembleRun)
#Add menus and scripts from nukeDict for every in nukeDict: subMenus = pluginsMenu.addMenu(every) for each in nukeDict[every]: cmd = each[0] subMenus.addCommand(cmd, 'nuke.createNode' + '("' + cmd + '")') ############################################################################################################ # Jeeves dependant things ############################################################################################################ if fullsetup: m = nuke.menu( 'Nuke' ).findItem('JEEVES/Connect to Jeeves') m.setEnabled( False ) 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', jeevesStatic.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')) else: turnoff = ["JEEVES/Save","JEEVES/Write", "JEEVES/Read"] for each in turnoff: m = nuke.menu( 'Nuke' ).findItem(each) m.setEnabled( False ) nuke.tprint ('\n''FINSHED NUKE MENU.PY''\n')
nuke.addFilenameFilter(myFilenameFilter) # Create OS specific variables (no Linux support) volProjects = '' volAssets = '' if(sys.platform == 'win32'): volProjects = 'X:' volAssets = 'Y:' elif(sys.platform == 'darwin'): volProjects = '/Volumes/Projects' volAssets = '/Volumes/Assets' # Make these favorites show up in Nuke nuke.addFavoriteDir('File server', volProjects + '/Projects/') nuke.addFavoriteDir('Assets', volAssets) nuke.addFavoriteDir('R&D', volProjects + '/RnD/') # Formats nuke.addFormat( '1024 576 PAL Widescreen' ) nuke.addFormat( '1280 720 HD 720p' ) # Set plugin/gizmo sub-folders nuke.pluginAppendPath(volAssets + '/include/nuke/gizmos') nuke.pluginAppendPath(volAssets + '/include/nuke/plugins') nuke.pluginAppendPath(volAssets + '/include/nuke/scripts') nuke.pluginAppendPath(volAssets + '/include/nuke/icons') # Load Bokeh os.environ['RLM_LICENSE'] = '[email protected]'
def init_shot_env(): global config homedir = os.path.expanduser('~') logfile = "" if sys.platform == 'win32': logfile = os.path.join(homedir, 'AppData', 'Local', 'IHPipeline', 'nuke_launch.log') elif sys.platform == 'darwin': logfile = os.path.join(homedir, 'Library', 'Logs', 'IHPipeline', 'nuke_launch.log') elif sys.platform == 'linux2': logfile = os.path.join(homedir, 'Logs', 'IHPipeline', 'nuke_launch.log') if not os.path.exists(os.path.dirname(logfile)): os.makedirs(os.path.dirname(logfile)) logFormatter = logging.Formatter( "%(asctime)s:[%(threadName)s]:[%(levelname)s]:%(message)s") log = logging.getLogger() log.setLevel(logging.DEBUG) fileHandler = logging.FileHandler(logfile) fileHandler.setFormatter(logFormatter) log.addHandler(fileHandler) consoleHandler = logging.StreamHandler() consoleHandler.setFormatter(logFormatter) log.addHandler(consoleHandler) script_path = os.path.normpath(nuke.root().name()) script_path_lst = script_path.split(os.path.sep) path_idx = 0 str_show_code = None str_shot = None str_seq = None try: str_show_code = os.environ['IH_SHOW_CODE'] except KeyError: log.warning( "IH_SHOW_CODE environment variable not defined. Proceeding without environment." ) return str_show_root = None try: str_show_root = os.environ['IH_SHOW_ROOT'] except KeyError: log.warning( "IH_SHOW_ROOT environment variable not defined. Proceeding without environment." ) return if not os.path.exists(str_show_root): log.warning("Show root directory does not exist at %s." % str_show_root) return cfg_shot_dir = config.get(str_show_code, 'shot_dir_format') cfg_seq_dir = config.get(str_show_code, 'seq_dir_format') cfg_shot_regexp = config.get(str_show_code, 'shot_regexp') cfg_seq_regexp = config.get(str_show_code, 'sequence_regexp') # were we called from within shotgun? b_shotgun = False b_shotgun_res = False engine = None ctx = None entity = None for envvar in os.environ.keys(): log.debug('ENVIRONMENT - %s: %s' % (envvar, os.environ[envvar])) try: toolkit_engine = os.environ['TANK_ENGINE'] b_shotgun = True log.info( 'Setting b_shotgun to True, os.environ[\'TANK_ENGINE\'] exists.') except: pass if not script_path.startswith(str_show_root): log.warning( "Unable to match show root directory with Nuke script path.") b_shotgun_res = True matchobject = re.search(cfg_shot_regexp, script_path) # make sure this file matches the shot pattern if not matchobject: log.warning( "This script name does not match the shot regular expression pattern for the show." ) b_shotgun_res = True else: str_shot = matchobject.group(0) str_seq = re.search(cfg_seq_regexp, str_shot).group(0) if b_shotgun: log.info("Nuke executed from within Shotgun Desktop Integration.") ctx = None try: import sgtk ctx = sgtk.Context.deserialize(os.environ['TANK_CONTEXT']) except KeyError: log.error("Envionrment variable TANK_CONTEXT not found.") except ImportError: log.error("Unable to import sgtk.") if ctx == None: log.warning( "Nuke executed within Shotgun, but the context associated with the current engine is None." ) else: log.info("Shotgun Toolkit Context Object:") log.info(ctx) entity = ctx.entity if entity == None: log.warning( "Nuke executed within Shotgun, but the entity associated with the current context is None." ) else: if entity['type'] != 'Shot': log.warning( "Nuke executed within Shotgun, but not in the context of a specific shot." ) else: if b_shotgun_res: log.info( "Nuke executed within Shotgun, but no active script available. Setting sequence and shot from current engine context." ) try: str_shot = entity['name'] str_seq = re.search(cfg_seq_regexp, str_shot).group(0) except KeyError: log.error( "For some reason, context provided by Shotgun to Nuke is %s. Unable to proceed." % ctx) str_shot = None if str_shot == None: log.warning( "Could not determine current shot from script name, or from database. Exiting init_shot_env()." ) return str_seq = re.search(cfg_seq_regexp, str_shot).group(0) log.info('Sequence is %s' % str_seq) log.info('Shot is %s' % str_shot) str_seq_path = "" str_shot_path = "" str_show_path = str_show_root str_shot_path = cfg_shot_dir.format(show_root=str_show_path, pathsep=os.path.sep, sequence=str_seq, shot=str_shot) str_seq_path = cfg_seq_dir.format(show_root=str_show_path, pathsep=os.path.sep, sequence=str_seq) str_show = str_show_code log.info("Located show %s, path %s" % (str_show, str_show_path)) log.info("Located sequence %s, path %s" % (str_seq, str_seq_path)) log.info("Located shot %s, path %s" % (str_shot, str_shot_path)) os.environ['SHOW'] = str_show os.environ['SHOW_PATH'] = str_show_path os.environ['SEQ'] = str_seq os.environ['SEQ_PATH'] = str_seq_path os.environ['SHOT'] = str_shot os.environ['SHOT_PATH'] = str_shot_path # add knobs to root, if they don't exist already root_knobs_dict = nuke.root().knobs() k_ih_tab = None k_ih_show = None k_ih_show_path = None k_ih_seq = None k_ih_seq_path = None k_ih_shot = None k_ih_shot_path = None try: k_ih_tab = root_knobs_dict['tab_inhouse'] except KeyError: k_ih_tab = nuke.Tab_Knob('tab_inhouse', 'In-House') nuke.root().addKnob(k_ih_tab) try: k_ih_show = root_knobs_dict['txt_ih_show'] except KeyError: k_ih_show = nuke.String_Knob('txt_ih_show', 'show') nuke.root().addKnob(k_ih_show) try: k_ih_show_path = root_knobs_dict['txt_ih_show_path'] except KeyError: k_ih_show_path = nuke.String_Knob('txt_ih_show_path', 'show path') nuke.root().addKnob(k_ih_show_path) try: k_ih_seq = root_knobs_dict['txt_ih_seq'] except KeyError: k_ih_seq = nuke.String_Knob('txt_ih_seq', 'sequence') nuke.root().addKnob(k_ih_seq) try: k_ih_seq_path = root_knobs_dict['txt_ih_seq_path'] except KeyError: k_ih_seq_path = nuke.String_Knob('txt_ih_seq_path', 'sequence path') nuke.root().addKnob(k_ih_seq_path) try: k_ih_shot = root_knobs_dict['txt_ih_shot'] except KeyError: k_ih_shot = nuke.String_Knob('txt_ih_shot', 'shot') nuke.root().addKnob(k_ih_shot) try: k_ih_shot_path = root_knobs_dict['txt_ih_shot_path'] except KeyError: k_ih_shot_path = nuke.String_Knob('txt_ih_shot_path', 'shot path') nuke.root().addKnob(k_ih_shot_path) k_ih_show.setValue(str_show) k_ih_show_path.setValue(str_show_path) k_ih_seq.setValue(str_seq) k_ih_seq_path.setValue(str_seq_path) k_ih_shot.setValue(str_shot) k_ih_shot_path.setValue(str_shot_path) # remove old favorite directories if they exist nuke_prefs_file = os.path.join(os.path.expanduser("~"), '.nuke', 'FileChooser_Favorites.pref') if os.path.exists(nuke_prefs_file): with open(nuke_prefs_file) as npf: for line in npf: if line.startswith('add_favorite_dir'): line_array = shlex.split(line) fav_name = line_array[1] if fav_name.startswith('SHOW') or fav_name.startswith( 'SEQ') or fav_name.startswith('SHOT'): nuke.removeFavoriteDir(fav_name) # add favorite directories in file browser # TODO: pull these values out of the show config file nuke.addFavoriteDir("SHOW", '[getenv IH_SHOW_ROOT]') if os.path.exists(os.path.join(str_show_root, 'SHARED')): nuke.addFavoriteDir("SHOW/SHARED", os.path.join('[getenv IH_SHOW_ROOT]', 'SHARED')) if os.path.exists(os.path.join(str_show_root, 'ref')): nuke.addFavoriteDir("SHOW/ref", os.path.join('[getenv IH_SHOW_ROOT]', 'ref')) if 'SEQUENCE' in cfg_shot_dir: nuke.addFavoriteDir("SEQ", '[getenv SEQ_PATH]') if os.path.exists(os.path.join(str_seq_path, 'SHARED')): nuke.addFavoriteDir("SEQ/SHARED", os.path.join('[getenv SEQ_PATH]', 'SHARED')) if os.path.exists(os.path.join(str_seq_path, 'ref')): nuke.addFavoriteDir("SEQ/ref", os.path.join('[getenv SEQ_PATH]', 'ref')) nuke.addFavoriteDir("SHOT", '[getenv SHOT_PATH]') # shot directories try: l_nukescript_dir = config.get('shot_structure', 'nukescript_dir').split('{pathsep}') l_plate_dir = config.get('shot_structure', 'plate_dir').split('{pathsep}') l_precomp_dir = config.get('shot_structure', 'precomp_dir').split('{pathsep}') l_rendercomp_dir = config.get('shot_structure', 'rendercomp_dir').split('{pathsep}') l_element_dir = config.get('shot_structure', 'element_dir').split('{pathsep}') l_renderelem_dir = config.get('shot_structure', 'renderelem_dir').split('{pathsep}') l_mograph_dir = config.get('shot_structure', 'mograph_dir').split('{pathsep}') l_ref_dir = config.get('shot_structure', 'ref_dir').split('{pathsep}') l_nukescript_dir.insert(0, r'[getenv SHOT_PATH]') l_plate_dir.insert(0, r'[getenv SHOT_PATH]') l_precomp_dir.insert(0, r'[getenv SHOT_PATH]') l_rendercomp_dir.insert(0, r'[getenv SHOT_PATH]') l_element_dir.insert(0, r'[getenv SHOT_PATH]') l_renderelem_dir.insert(0, r'[getenv SHOT_PATH]') l_mograph_dir.insert(0, r'[getenv SHOT_PATH]') l_ref_dir.insert(0, r'[getenv SHOT_PATH]') log.info( 'Successfully retrieved Shot directory structure from config file.' ) log.info(l_nukescript_dir) log.info(os.path.sep.join(l_nukescript_dir)) nuke.addFavoriteDir("SHOT/nuke", os.path.sep.join(l_nukescript_dir)) nuke.addFavoriteDir("SHOT/plates", os.path.sep.join(l_plate_dir)) nuke.addFavoriteDir("SHOT/precomp", os.path.sep.join(l_precomp_dir)) nuke.addFavoriteDir("SHOT/comp", os.path.sep.join(l_rendercomp_dir)) nuke.addFavoriteDir("SHOT/elements", os.path.sep.join(l_element_dir)) nuke.addFavoriteDir("SHOT/renders", os.path.sep.join(l_renderelem_dir)) nuke.addFavoriteDir("SHOT/mograph", os.path.sep.join(l_mograph_dir)) nuke.addFavoriteDir("SHOT/ref", os.path.sep.join(l_ref_dir)) except Exception as e: log.warning( "Caught exception %s when attempting to extract shot structure from the config file. Reverting to hard-coded shortcut paths." % type(e).__name__) log.warning(traceback.format_exc()) nuke.addFavoriteDir("SHOT/nuke", os.path.join('[getenv SHOT_PATH]', 'nuke')) nuke.addFavoriteDir( "SHOT/plates", os.path.join('[getenv SHOT_PATH]', 'pix', 'plates')) nuke.addFavoriteDir( "SHOT/precomp", os.path.join('[getenv SHOT_PATH]', 'pix', 'precomp')) nuke.addFavoriteDir("SHOT/comp", os.path.join('[getenv SHOT_PATH]', 'pix', 'comp')) nuke.addFavoriteDir( "SHOT/elements", os.path.join('[getenv SHOT_PATH]', 'pix', 'elements')) nuke.addFavoriteDir( "SHOT/renders", os.path.join('[getenv SHOT_PATH]', 'pix', 'renders')) nuke.addFavoriteDir( "SHOT/mograph", os.path.join('[getenv SHOT_PATH]', 'pix', 'mograph')) nuke.addFavoriteDir("SHOT/ref", os.path.join('[getenv SHOT_PATH]', 'ref'))
menubar = nuke.menu('Nuke') RfxMenu = menubar.addMenu('Tools') RfxMenu.addCommand('Test T01', 'nuke.createNode("Transform")') RfxMenu.addCommand('Test T02', lambda: nuke.nodes.Transform()) RfxMenu.addCommand('Fix Reads', "import fixReads;reload(fixReads);fixReads.start()") RfxMenu.addCommand( 'Split EXR Channels', "import splitChannel;reload(splitChannel);splitChannel.split()") menu_name = "TESTMENU" menu_generator = menu_gen.NukeMenuGenerator(menu_name) menu_generator.create_menu() # Add custom menu to the toolbar(also in r_click menu of the node graph) nodes = nuke.menu('Nodes') gizmos = nodes.addMenu('Gizmos', icon='NAS-52.png') gizpath = os.path.join(root, 'gizmos') for gizmo in os.listdir(gizpath): if os.path.splitext(gizmo)[-1] == '.gizmo': name = os.path.splitext(gizmo)[0] ico = name + '.png' gizmos.addCommand(name, "nuke.createNode('{0}')".format(name, icon=ico)) # add favorite directories in file browser nuke.addFavoriteDir('pipeline', root, nuke.IMAGE | nuke.GEO) os.environ['JOB'] = os.path.normpath(r'C:\dev\assetsUsd') nuke.addFavoriteDir('JOB', '[getenv JOB]')
shot = 'shotNotSet' theBoatFolder = 'theBoatFolderNotSet' if os.environ.get("THEBOATFOLDER"): theBoatFolder = os.environ.get("THEBOATFOLDER") if os.environ.get("JOB"): job = os.environ.get("JOB") if os.environ.get("SHOT"): shot = os.environ.get("SHOT") nuke.tprint("theBoatFolder: {}\njob: {}\nshot: {}".format( theBoatFolder, job, shot)) shotPath = os.path.join(theBoatFolder, job, shot) nuke.addFavoriteDir(shot, shotPath) # THE BOAT TOOLBAR toolbar = nuke.toolbar("Nodes") # Access the main toolbar theboatNodes = toolbar.addMenu("theboat", icon=theBoatConfigFolder + '/icons/boatIcon.png') generalNodes = theboatNodes.addMenu("theboat", icon=theBoatConfigFolder + '/icons/hoveringSombreroIcon.png') #LUMA'S GIZMO PATH MANAGER if __name__ == '__main__': gizManager = globals().get('gizManager', None) if gizManager is None: print 'Problem finding GizmoPathManager - check that init.py was setup correctly'
m.addCommand('Flipbook Selected in &DJV', 'nukescripts.flipbook( djv_this.djv_this, \ nuke.selectedNode() )', 'Ctrl+F', index=9) ### END DJVIEW SETUP ### ### BEGIN OCIO SETUP ### import nukescripts.ViewerProcess; nukescripts.ViewerProcess.unregister_viewers() import nukescripts.ViewerProcess; nukescripts.ViewerProcess.register_viewers(defaultLUTS = False,\ ocioConfigName = os.environ.get('OCIO', None)); ### END OCIO SETUP ### ### BEGIN FAVORITES SETUP ### ## Add Favorites directories nuke.addFavoriteDir('Job Server', jobServer ) toolbar = nuke.toolbar("Nodes") ### END FAVORITES SETUP ### ### BEGIN DEFAULTS SETUP ### nuke.addOnUserCreate(firstFrameEval, nodeClass = 'FrameHold') nuke.addOnUserCreate(guiOn, nodeClass = 'DiskCache') ### END DEFAULTS SETUP ### ### BEGIN LUMA GIZMO SETUP ### ## LUMA Pictures gizmo collector if __name__ == '__main__':
# Setup Global copy/paste menubar = nuke.menu('Nuke') menu = menubar.menu('Edit') path = os.path.join(os.environ["STUDIO_TMP"], "global_nuke_tmp.nk") menu.addCommand("Global Copy", "nuke.nodeCopy(\"{0}\")".format(path), "shift+alt+c", index=5) menu.addCommand("Global Paste", "nuke.nodePaste(\"{0}\")".format(path), "shift+alt+v", index=7) # Setup common directories. nuke.addFavoriteDir("Studio Library", "//10.10.200.11/171000_TGB_Library/Stock") # Backup Nuke script on save. def on_script_save(): source = nuke.root().name() if not os.path.exists(source): return target = os.path.abspath( os.path.join( source, "..", "workspace", "backup", "{0}_{1}.nk".format( os.path.basename(os.path.splitext(source)[0]), datetime.datetime.now().strftime("%Y%m%d%H%M%S"))))
'TimeOffset': '[value time_offset]', 'Vectorfield': '[file tail [value vfield_file]]', } for node, val in label_defaults.items(): nuke.knobDefault('{0}.label'.format(node), val) # Add default favorite directories that appear in the file browser. favorite_dirs = { # 'dev': '/cave/dev', # 'vault': '/cave/vault', # 'hdri': '/cave/vault/hdri', # 'stock': '/cave/vault/stock', # 'proj': '/cave/proj', } for name, path in sorted(list(favorite_dirs.items()), key=lambda k_v: k_v[0]): nuke.addFavoriteDir(name, path, nuke.IMAGE | nuke.SCRIPT | nuke.GEO | nuke.PYTHON) # Set default formats. Note this expects an empty formats.tcl in the NUKE_PATH to clear the existing default formats. default_formats = [ '854 480 1 SD_480p', '960 540 1 SD_540p', '1280 720 1 HD_720p', '1920 1080 1 HD_1080p', '2560 1440 1 UHD_1440p', '3840 2160 1 UHD_4k', '2048 1556 1 2K_Super_35_full-ap', '1828 1556 2 2K_Cinemascope', '2048 1080 1 2K_DCP', '4096 3112 1 4K_Super_35_full-ap', '3656 3112 2 4K_Cinemascope', '4096 2160 1 4K_DCP',
'helga_assets': ['helga_assets', PIPELINE_ASSETS_PATH, display_type, favorite_icon], 'helga_shots': ['helga_shots', PIPELINE_SHOTS_PATH, display_type, favorite_icon], 'helga_props': ['helga_props', PIPELINE_WORK_PROPS_PATH, display_type, favorite_icon], 'helga_rnd': ['helga_rnd', PIPELINE_RND_PATH, display_type, favorite_icon] } #iterate and set for value_list in sorted(favorite_dict.values()): #extract info favorite_name, favorite_path, favorite_display_type, favorite_icon = value_list #add to favorites nuke.addFavoriteDir(favorite_name, favorite_path, favorite_display_type, favorite_icon) #SuccessMsg nuke.tprint('Successfully added pathes to favorites') except: #FailMsg nuke.tprint('Error adding favorites to file browser') #Create helga menu (Nodes) #------------------------------------------------------------------ try: #Main Menubar helga_main_menu = nuke.menu('Nodes').addMenu('Helga',
def __setup_favorite_dirs(self): """ Sets up nuke shortcut "favorite dirs" that are presented in the left hand side of Nuke common dialogs (open, save). Nuke currently only writes favorites to disk in ~/.nuke/folders.nk. If you add/remove one in the UI. Doing them via the api only updates them for the session (Nuke bug #3740). See http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=3481&start=15 """ engine_root_dir = self.disk_location sg_logo = os.path.abspath(os.path.join(engine_root_dir, "resources", "sg_logo_80px.png")) # Ensure old favorites we used to use are removed. supported_entity_types = ["Shot", "Sequence", "Scene", "Asset", "Project"] for x in supported_entity_types: nuke.removeFavoriteDir("Tank Current %s" % x) nuke.removeFavoriteDir("Tank Current Work") nuke.removeFavoriteDir("Shotgun Current Project") nuke.removeFavoriteDir("Shotgun Current Work") # Add favorties for current project root(s). proj = self.context.project current_proj_fav = self.get_setting("project_favourite_name") # Only add these current project entries if we have a value from settings. # Otherwise, they have opted to not show them. if proj and current_proj_fav: proj_roots = self.tank.roots for root_name, root_path in proj_roots.items(): dir_name = current_proj_fav if len(proj_roots) > 1: dir_name += " (%s)" % root_name # Remove old directory nuke.removeFavoriteDir(dir_name) # Add new path nuke.addFavoriteDir(dir_name, directory=root_path, type=(nuke.IMAGE | nuke.SCRIPT | nuke.GEO), icon=sg_logo, tooltip=root_path) # Add favorites directories from the config for favorite in self.get_setting("favourite_directories"): # Remove old directory nuke.removeFavoriteDir(favorite['display_name']) try: template = self.get_template_by_name(favorite['template_directory']) fields = self.context.as_template_fields(template) path = template.apply_fields(fields) except Exception as e: msg = "Error processing template '%s' to add to favorite " \ "directories: %s" % (favorite['template_directory'], e) self.logger.exception(msg) continue # Add new directory icon_path = favorite.get('icon') if not os.path.isfile(icon_path) or not os.path.exists(icon_path): icon_path = sg_logo nuke.addFavoriteDir(favorite['display_name'], directory=path, type=(nuke.IMAGE | nuke.SCRIPT | nuke.GEO), icon=icon_path, tooltip=path)
import nuke, os, sys from amg import icons nuke.tprint('============== init.py is running\n') # nuke root NUKE_PATH = os.path.join(os.getenv('AMG_ROOT'), 'scripts', 'nuke') #add plugin path nuke.pluginAddPath(os.path.join(NUKE_PATH, 'gizmos').replace('\\','/')) nuke.pluginAddPath(os.path.join(NUKE_PATH, 'icons').replace('\\','/')) nuke.pluginAddPath(os.path.join(os.getenv('AMG_PLUGINS'), 'nuke')) # python os.environ['PYTHONPATH'] = os.path.join(NUKE_PATH, 'python') #favorites nuke.addFavoriteDir( 'AMG', '[getenv AMG_ROOT]', nuke.IMAGE | nuke.GEO | nuke.FONT | nuke.PYTHON, icon=icons.ico['animagrad'] )
import nuke, os, sys from amg import icons nuke.tprint('============== init.py is running\n') # nuke root NUKE_PATH = os.path.join(os.getenv('AMG_ROOT'), 'scripts', 'nuke') #add plugin path nuke.pluginAddPath(os.path.join(NUKE_PATH, 'gizmos').replace('\\', '/')) nuke.pluginAddPath(os.path.join(NUKE_PATH, 'icons').replace('\\', '/')) nuke.pluginAddPath(os.path.join(os.getenv('AMG_PLUGINS'), 'nuke')) # python os.environ['PYTHONPATH'] = os.path.join(NUKE_PATH, 'python') #favorites nuke.addFavoriteDir('AMG', '[getenv AMG_ROOT]', nuke.IMAGE | nuke.GEO | nuke.FONT | nuke.PYTHON, icon=icons.ico['animagrad'])
def setFavorites(self): nuke.removeFavoriteDir('Nuke') nuke.addFavoriteDir('DotNuke', os.path.expanduser('~/.nuke'), 0) nuke.addFavoriteDir('Jobs', '/', 0) nuke.addFavoriteDir('Fonts', '/', nuke.FONT)
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 __setup_favorite_dirs(self): """ Sets up nuke shortcut "favorite dirs" that are presented in the left hand side of Nuke common dialogs (open, save). Nuke currently only writes favorites to disk in ~/.nuke/folders.nk. If you add/remove one in the UI. Doing them via the api only updates them for the session (Nuke bug #3740). See http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=3481&start=15 """ engine_root_dir = self.disk_location sg_logo = os.path.abspath(os.path.join(engine_root_dir, "resources", "sg_logo_80px.png")) # Ensure old favorites we used to use are removed. supported_entity_types = ["Shot", "Sequence", "Scene", "Asset", "Project"] for x in supported_entity_types: nuke.removeFavoriteDir("Tank Current %s" % x) nuke.removeFavoriteDir("Tank Current Work") nuke.removeFavoriteDir("Shotgun Current Project") nuke.removeFavoriteDir("Shotgun Current Work") # Add favorties for current project root(s). proj = self.context.project current_proj_fav = self.get_setting("project_favourite_name") # Only add these current project entries if we have a value from settings. # Otherwise, they have opted to not show them. if proj and current_proj_fav: proj_roots = self.tank.roots for root_name, root_path in proj_roots.items(): dir_name = current_proj_fav if len(proj_roots) > 1: dir_name += " (%s)" % root_name # Remove old directory nuke.removeFavoriteDir(dir_name) # Add new path nuke.addFavoriteDir(dir_name, directory=root_path, type=(nuke.IMAGE|nuke.SCRIPT|nuke.GEO), icon=sg_logo, tooltip=root_path) # Add favorites directories from the config for favorite in self.get_setting("favourite_directories"): # Remove old directory nuke.removeFavoriteDir(favorite['display_name']) try: template = self.get_template_by_name(favorite['template_directory']) fields = self.context.as_template_fields(template) path = template.apply_fields(fields) except Exception, e: msg = "Error processing template '%s' to add to favorite " \ "directories: %s" % (favorite['template_directory'], e) self.log_exception(msg) continue # Add new directory icon_path = favorite.get('icon') if not os.path.isfile(icon_path) or not os.path.exists(icon_path): icon_path = sg_logo nuke.addFavoriteDir(favorite['display_name'], directory=path, type=(nuke.IMAGE|nuke.SCRIPT|nuke.GEO), icon=icon_path, tooltip=path)
# 256 pipeline tools # INTERFACE MANIPULATIONS # Create custom menu for NUKE import nuke, os, sys import shotAssembler # Add favorite dir nuke.addFavoriteDir('COMP', '{}PROD/2D/COMP'.format(rootProject)) menubar = nuke.menu('Nuke') dna = menubar.addMenu('DNA') dna.addCommand('ASSEMBLER', shotAssembler.assembleRun)
# reduce keyframes import reduceKeyframes m=nuke.menu( 'Animation' ) m.addCommand( 'Reduce Keyframes', "reduceKeyframes.doReduceKeyframes()" ) # method to add Frank Rueters Search and Replace panel def addSRPanel(): myPanel = SearchReplacePanel.SearchReplacePanel() return myPanel.addToPane() nuke.menu('Pane').addCommand('SearchReplace', addSRPanel) nukescripts.registerPanel('com.ohufx.SearchReplace', addSRPanel) ### add favourite directories nuke.addFavoriteDir ('Current Script', '[file dirname [value root.name]]', nuke.IMAGE | nuke.SCRIPT, icon='script_folder.png') # call the function 'my_function' from the my_code.py file nuke.menu('Nuke').addCommand('Chetan/Lower Settings', 'my_code.lower_settings()') nuke.menu('Nuke').addCommand('Chetan/Quick 3D', 'my_code.quick_3d()', 'shift+o') nuke.menu('Nuke').addCommand('Chetan/Open Folder', 'my_code.open_main()', 'shift+o') ### add format resolutions presets - i.e.: nuke.addFormat ('1920 797 0 0 1920 797 1.0 FullHD_Widescreen') nuke.addFormat ('1920 797 0 0 1920 797 1.0 FullHD_Widescreen') ### add LUT to the Root - i.e.: nuke.root().knob('luts').addCurve('nameOfTheLUT', 'formula') # sLOG formula example: '{pow(10.0, ((t - 0.616596 - 0.03) /0.432699)) - 0.037584}' ### customise menu items from Nodes toolbar - i.e. Shuffle hotkey 'J': nuke.menu('Nodes').addCommand('Channel/Shuffle', 'nuke.createNode("Shuffle")', 'j', icon='Shuffle.png')
### END DJVIEW SETUP ### ### BEGIN OCIO SETUP ### try: import nukescripts.ViewerProcess; nukescripts.ViewerProcess.unregister_viewers() import nukescripts.ViewerProcess; nukescripts.ViewerProcess.register_viewers(defaultLUTS = False,\ ocioConfigName = os.environ.get('OCIO', None)); except: print "OCIO var not set, using Default OCIO" ### END OCIO SETUP ### ### BEGIN FAVORITES SETUP ### ## Add Favorites directories nuke.addFavoriteDir('Job Server', jobServer ) if job: nuke.addFavoriteDir('Job', job) if seq: nuke.addFavoriteDir('Sequence', seq) if shot: nuke.addFavoriteDir('Shot', shot) toolbar = nuke.toolbar("Nodes") ### END FAVORITES SETUP ### ### BEGIN DEFAULTS SETUP ### nuke.addOnUserCreate(firstFrameEval, nodeClass = 'FrameHold') nuke.addOnUserCreate(guiOn, nodeClass = 'DiskCache')
import os import nuke import gizmos import disconnect_wiggle import plugin_nuke # auto load all gizmos gizmosPath = "//bigfoot/jellyfish/00_pipeline/nuke/gizmos" nuke.pluginAddPath(gizmosPath) menuNodes = nuke.menu('Nodes') gizmos.addGizmos(gizmosPath, menuNodes) # load render threads menuMain = nuke.menu('Nodes').menu("Jellyfish") menuMain.addCommand("vuRenderThreads", "plugin_nuke.showPopup()", "Alt+F7") # set up defaults nuke.knobDefault("Root.format", "HD_1080") nuke.knobDefault("Root.fps", os.environ['FPS']) # set up favorites jf = os.environ['ROOT'].replace("\\", "/") nuke.addFavoriteDir('JELLYFISH', jf) nuke.addFavoriteDir('JF USER', os.environ['HOME']) nuke.addFavoriteDir('JF SHOTS', jf + '/30_shots') nuke.addFavoriteDir('JF RENDER', jf + '/40_render') nuke.addFavoriteDir('JF FOOTAGE', jf + '/45_footage')
return # CREATE PANEL p = NkPanel( nkScripts ) # ADJUST SIZE p.setMinimumSize( 200, 200 ) # IF PANEL WAS CONFIRMED AND A NUKE SCRIPT WAS SELECTED, OPEN IT if p.showModalDialog(): if p.selectedScript: nuke.scriptOpen( p.selectedScript ) if SHOWln and SHOT != 0: ##Execute this #myLabel = os.path.join(newParts) myPath = os.path.join(SHOWln, "%s" % EP, "%s" % SEQ, "%s" % SHOT) #myPath3D = os.path.join(SHOWln, "%s" % EP, "%s" % SEQ, "%s" % SHOT) nuke.addFavoriteDir('Nuke Scripts', nukeDir()) nuke.addFavoriteDir('Shot Directory', myPath) #nuke.addFavoriteDir('3D Renders', myPath/release) else: print 'shot does not exist'