def addIconPath(base_dir): """ @param base_dir: @return: """ icons_mocha_dir = replace_path(os.path.join(base_dir, "python/mamoworld/mochaImportPlus/icons")) nuke.pluginAddPath(icons_mocha_dir)
def load(): supportedMagicNumbers = ['03f30d0a', 'd1f20d0a', '420d0d0a'] try: if nuke.NUKE_VERSION_STRING.startswith('13'): magicNumberOfThisVersion = imp.get_magic().hex() else: magicNumberOfThisVersion = imp.get_magic().encode('hex') if magicNumberOfThisVersion in supportedMagicNumbers: pathToThisVersion = "python/mamoworld/mochaImportPlus/version_" + magicNumberOfThisVersion nuke.pluginAddPath(pathToThisVersion) print('**--**-*-*-*-*' + magicNumberOfThisVersion) else: raise Exception( "MochaImport+ for NUKE: unsupported version of Python:" + sys.version + "(magic number:" + magicNumberOfThisVersion + ")") except Exception as e: import traceback nuke.tprint(traceback.format_exc()) # Just in case msg = 'ERROR: %s' % e if nuke.GUI: nuke.message(msg) else: nuke.tprint(msg)
def loadMochaimport(base_dir): """ adds the correct plugin path for this version of NUKE @param basepath: @return: """ supportedMagicNumbers = ['03f30d0a', 'd1f20d0a'] try: magicNumberOfThisVersion = imp.get_magic().encode('hex') if magicNumberOfThisVersion in supportedMagicNumbers: pathToThisVersion = replace_path( os.path.join( base_dir, "python/mamoworld/mochaImportPlus/version_" + magicNumberOfThisVersion)) nuke.pluginAddPath(pathToThisVersion) else: raise Exception( "MochaImport+ for NUKE: unsupported version of Python:" + sys.version + "(magic number:" + magicNumberOfThisVersion + ")") except Exception as e: import traceback nuke.tprint(traceback.format_exc()) # Just in case msg = 'ERROR: %s' % e if nuke.GUI: nuke.message(msg) else: nuke.tprint(msg)
def post_app_init(self): """ Called when all apps have initialized """ # render the menu! if self._ui_enabled: # note! not using the import as this confuses nuke's calback system # (several of the key scene callbacks are in the main init file...) import tk_nuke menu_name = "Shotgun" if self.get_setting("use_sgtk_as_menu_name", False): menu_name = "Sgtk" self._menu_generator = tk_nuke.MenuGenerator(self, menu_name) self._menu_generator.create_menu() self.__setup_favorite_dirs() # iterate over all apps, if there is a gizmo folder, add it to nuke path for app in self.apps.values(): # add gizmo to nuke path app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # now translate the path so that nuke is happy on windows app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.log_debug("Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH" % app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # and also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder)
def changeVersion(self, iAObj=None, applicationObject=None): old_gizmo = nuke.toNode(applicationObject) file_path = iAObj.filePath.replace('\\', '/') gizmo_path = os.path.dirname(file_path) nuke.pluginAddPath(gizmo_path) new_gizmo = nuke.createNode(file_path) # connect inputs for i in range(old_gizmo.inputs()): new_gizmo.setInput(i, old_gizmo.input(i)) # connect outputs for d in old_gizmo.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS): for input in [ i for i in range(d.inputs()) if d.input(i) == old_gizmo ]: d.setInput(input, new_gizmo) # restore ititial position new_gizmo.setXYpos(old_gizmo.xpos(), old_gizmo.ypos()) # swap them over nuke.delete(old_gizmo) new_gizmo['name'].setValue(iAObj.assetName) self.addFTab(new_gizmo) self.setFTab(new_gizmo, iAObj) return True
def post_app_init(self): """ Called when all apps have initialized """ # render the menu! if self._ui_enabled: # note! not using the import as this confuses nuke's calback system # (several of the key scene callbacks are in the main init file...) import tk_nuke menu_name = "Shotgun" if self.get_setting("use_sgtk_as_menu_name", False): menu_name = "Sgtk" self._menu_generator = tk_nuke.MenuGenerator(self, menu_name) self._menu_generator.create_menu() self.__setup_favorite_dirs() # iterate over all apps, if there is a gizmo folder, add it to nuke path for app in self.apps.values(): # add gizmo to nuke path app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # now translate the path so that nuke is happy on windows app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.log_debug( "Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH" % app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # and also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder)
def post_app_init_nuke(self, menu_name="Shotgun"): """ The Nuke-specific portion of the engine's post-init process. :param menu_name: The label/name of the menu to be created. """ if self.has_ui and not self.studio_enabled: # Note! not using the import as this confuses Nuke's callback system # (several of the key scene callbacks are in the main init file). import tk_nuke # Create the menu! self._menu_generator = tk_nuke.NukeMenuGenerator(self, menu_name) self._menu_generator.create_menu() # Initialize favourite dirs in the file open/file save dialogs self.__setup_favorite_dirs() # Register all panels with nuke's callback system # this will be used at nuke startup in order # for nuke to be able to restore panels # automatically. For all panels that exist as # part of saved layouts, nuke will look through # a global list of registered panels, try to locate # the one it needs and then run the callback. for (panel_id, panel_dict) in self.panels.iteritems(): nukescripts.panels.registerPanel( panel_id, panel_dict["callback"], ) # Iterate over all apps, if there is a gizmo folder, add it to nuke path. for app in self.apps.values(): # Add gizmos to nuke path. app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # Now translate the path so that nuke is happy on Windows. app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.logger.debug( "Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH", app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # And also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder) # Nuke Studio 9 really doesn't like us running commands at startup, so don't. if not (nuke.env.get("NukeVersionMajor") == 9 and nuke.env.get("studio")): self._run_commands_at_startup() try: self.log_user_attribute_metric("Nuke version", nuke.env.get("NukeVersionString")) except: # ignore all errors. ex: using a core that doesn't support metrics pass
def init_app(self): """ Called as the application is being initialized """ # first, we use the special import_module command to access the app module # that resides inside the python folder in the app. This is where the actual UI # and business logic of the app is kept. By using the import_module command, # toolkit's code reload mechanism will work properly. #app_payload = self.import_module("app") # now register a *command*, which is normally a menu entry of some kind on a Shotgun # menu (but it depends on the engine). The engine will manage this command and # whenever the user requests the command, it will call out to the callback. # Get Current Shotgun Toolkit path #tk = sgtk.sgtk_from_entity(context.project["type"], context.project["id"]) #sgtk_path = str(tk).split(" ")[-1] sgtk_python_path = sgtk.get_sgtk_module_path() sgtk_config_path = os.path.join( sgtk_python_path.split("install")[0], "config") # Check if hook folder exists, this app will not work without making a bespoke lut gizmo and script. app_hook_path = os.path.join(sgtk_config_path, "hooks", "tk-nuke", "tk-nuke-lut-app") if not os.path.exists(app_hook_path): os.makedirs(app_hook_path) self.logger.info("Created Hooks folder: tk-nuke/tk-nuke-lut-app") # # Copy over the update_lut.py # callback_script = "update_lut.py" # src = os.path.join(os.path.dirname(__file__), "resources", callback_script) # dst = os.path.join(app_hook_path, callback_script) # if not os.path.exists(dst): # shutil.copy2(src, dst) # self.logger.info("Copied "+callback_script+" script to hooks folder because it did not exist yet.") # # Copy over the example init.py # resource = "init.py" # src = os.path.join(os.path.dirname(__file__), "resources", resource) # dst = os.path.join(app_hook_path, resource) # if not os.path.exists(dst): # shutil.copy2(src, dst) # self.logger.info("Copied "+resource+" script to hooks folder because it did not exist yet.") # Adding hook folder to Nuke Path so the custom gizmo and script can be picked up nuke.pluginAddPath(app_hook_path) self.logger.error("Adding " + app_hook_path + " to nuke plugin path") # first, set up our callback, calling out to a method inside the app module contained # in the python folder of the app menu_callback = lambda: loadLut() # now register the command with the engine self.engine.register_command("Load Viewer LUT...", menu_callback) # Callbacks nuke.addOnScriptSave(loadLut()) nuke.addOnScriptLoad(loadLut())
def NukePythonPath(): sys.path.append('/Python27/Lib/site-packages') print "\n===========================" nukeIntitialPath = os.getenv('CYC_ENGINE_NUKE') nuke.pluginAddPath(os.path.join(nukeIntitialPath, 'NukeCallbacks')) print "%s/NukeCallbacks Path added" % (nukeIntitialPath) nuke.pluginAddPath('%s/NukeTools_%s' % (nukeIntitialPath, NukeMenuVersion)) print "%s/NukeTools_%s Path added" % (nukeIntitialPath, NukeMenuVersion)
def add_plugin_paths(): # ADD all IMG paths for img in os.getenv('IMG_PATH').split(';'): for img_sub in libFunc.get_deep_folder_list(path=img, add_path=True): nuke.pluginAddPath(img_sub) # ADD sub software paths for paths in os.getenv('SOFTWARE_SUB_PATH').split(';'): nuke.pluginAddPath(paths)
def initScripts(): excludeList = openFileReturnArr(currentPref) if os.path.isdir(scriptsPath): scripts = getScripts(scriptsPath) for script in scripts: if script not in excludeList: nuke.pluginAddPath("{scriptsPath}/{script}".format(scriptsPath=os.path.dirname(scriptsPath), script=script)) else: nuke.message("could'nt find the python script path")
def _builMenuFromPath(self, menu, basepath, module): items = [] path = os.path.join(basepath,module) try: for i in os.listdir(path): if os.path.isdir(os.path.join(path,i)): nuke.pluginAddPath(path) submnu = menu.addMenu(i, icon=(i + ".png")) self._builMenuFromPath(submnu, path, i) else: name, extesion = os.path.splitext(i) if extesion.lower() in [".py"]: if name != "__init__": items.append(["f", name]) # Generate __init__.py if its not exsist. initfile = os.path.join(path, "__init__.py") if not os.path.exists(initfile): open(initfile, "w").close() elif extesion.lower() == ".gizmo": items.append(["g", name]) elif extesion.lower() == ".nk": items.append(["s", name]) except : print "Error while searching for items in module" if len(items) > 0: nuke.pluginAddPath(path) for item in items: ftype, fname = item if ftype == "f": try: name, hotkey, help, version, call = self._getFunctionFromModule(module, fname) menu.addCommand(name+ " (v" + version +")", call, hotkey , icon=(fname+".png")) except Exception, e: print "Error while loading " + fname, "\n ",type(e), "\n " , e,"\n" elif ftype == "g": menu.addCommand(fname, "nuke.createNode('%s')" % fname ,icon=(fname+".png")) elif ftype == "s": menu.addCommand(fname, "nuke.scriptSource('%s')" % os.path.join(path, fname + ".nk") ,icon=(fname+".png"))
def walkThruGizmos(directory): #os walk thru gizmoPath,folder names are menu names for path, dirs, files in os.walk(directory): dirs.sort() files.sort() for f in files: if f.endswith(".gizmo"): path = path.replace("\\", "/") #avoid backup folders if not "_backup" in path: nuke.pluginAddPath(path) prntPath = path + '/' + f
def post_app_init_nuke(self, menu_name="Shotgun"): """ The Nuke-specific portion of the engine's post-init process. :param menu_name: The label/name of the menu to be created. """ if self.has_ui and not self.studio_enabled: # Note! not using the import as this confuses Nuke's callback system # (several of the key scene callbacks are in the main init file). import tk_nuke # Create the menu! self._menu_generator = tk_nuke.NukeMenuGenerator(self, menu_name) self._menu_generator.create_menu() # Initialize favourite dirs in the file open/file save dialogs self.__setup_favorite_dirs() # Register all panels with nuke's callback system # this will be used at nuke startup in order # for nuke to be able to restore panels # automatically. For all panels that exist as # part of saved layouts, nuke will look through # a global list of registered panels, try to locate # the one it needs and then run the callback. for (panel_id, panel_dict) in self.panels.iteritems(): nukescripts.panels.registerPanel( panel_id, panel_dict["callback"], ) # Iterate over all apps, if there is a gizmo folder, add it to nuke path. for app in self.apps.values(): # Add gizmos to nuke path. app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # Now translate the path so that nuke is happy on Windows. app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.log_debug("Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH" % app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # And also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder) try: self.log_user_attribute_metric("Nuke version", nuke.env.get("NukeVersionString")) except: # ignore all errors. ex: using a core that doesn't support metrics pass
def load_gizmos(): var = os.environ.get('ST_NUKE_GIZMOS') gizmos = [] if var != None: gizmos = var.split(';') for g in gizmos: gizmopath = os.path.expandvars(g) nuke.pluginAddPath(gizmopath) for path, dirs, files in os.walk(gizmopath): try: path = path.replace("\\", "/") nuke.pluginAddPath(path) except: print("Could not load plugin path {0}".format(path))
def post_app_init(self): """ Called when all apps have initialized """ # render the menu! if self._ui_enabled: # note! not using the import as this confuses nuke's calback system # (several of the key scene callbacks are in the main init file...) import tk_nuke menu_name = "Shotgun" if self.get_setting("use_sgtk_as_menu_name", False): menu_name = "Sgtk" # create menu self._menu_generator = tk_nuke.MenuGenerator(self, menu_name) self._menu_generator.create_menu() # initialize favourite dirs in the file open/file save dialogs self.__setup_favorite_dirs() # register all panels with nuke's callback system # this will be used at nuke startup in order # for nuke to be able to restore panels # automatically. For all panels that exist as # part of saved layouts, nuke will look through # a global list of registered panels, try to locate # the one it needs and then run the callback for (panel_id, panel_dict) in self.panels.iteritems(): nukescripts.panels.registerPanel(panel_id, panel_dict["callback"]) # iterate over all apps, if there is a gizmo folder, add it to nuke path for app in self.apps.values(): # add gizmo to nuke path app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # now translate the path so that nuke is happy on windows app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.log_debug( "Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH" % app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # and also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder)
def add_nuke_menu(): """ Adds a "Panels" menu to the Nuke menubar. """ try: package_dir = dirname(dirname(sys.modules['PythonEditor'].__file__)) nuke.pluginAddPath(package_dir) except Exception as error: print(error) nuke_menu = nuke.menu('Nuke') panel_menu = nuke_menu.addMenu('Panels') panel_menu.addCommand('Python Editor', IMPORT_CMD, icon=ICON_PATH) panel_menu.addCommand('[dev] Fully Reload Python Editor', RELOAD_CMD, icon=ICON_PATH)
def addPathToPlugins( plugin_path ): for dirpath, dirnames, filenames in os.walk( plugin_path, followlinks=True ): logging.debug( "---" ) logging.debug( dirpath ) logging.debug( dirnames ) logging.debug( filenames ) if re.match(".*/python$", dirpath) : #or re.match(".*/py$", dirpath): # this is required for us to source jops directly nuke.pluginAddPath( dirpath, addToSysPath=True ) else: nuke.pluginAddPath( dirpath, addToSysPath=False ) if "__init__.py" in filenames: # then this must be a python module to be added to sys.path logging.debug( "Python module detected %s. Adding parent to syspath %s" % (os.path.basename(dirpath), os.path.dirname(dirpath)) ) sys.path.append( os.path.dirname(dirpath) )
def load_and_create_plugin(plugin, plugin_path): """ Dynamically in nuke loads a plugin given a path to the plugin and a plugin name. If plugin doesn't exist lets user know and does nothing :param plugin: name of the plugin without extension. ie: AOV_CC, not AOV_CC.gizmo :param plugin_path: absolute path to directory with the plugin """ nuke.pluginAddPath(plugin_path) logging.info("Adding plugin path {0} and loading plugin {1}".format(plugin_path, plugin)) # try to load, since nuke doesn't return an error just throws a runtime exception. try: nuke.load(plugin) nuke.createNode(plugin) except RuntimeError as e: error = "Could not load the plugin named {0}. Error is {1}".format(plugin, e) logging.exception(error) nuke.message(error)
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 add_python_paths(self): """ Add the paths for python modules """ self.logger.info("Adding python paths.") nuke.pluginAddPath(self.python_path) self.logger.info("Added root path: {0}".format(self.python_path)) for mod in os.listdir(self.python_path): if self.re_excludes.match(mod): continue mod_path = _convert2slash(os.path.join(self.python_path, mod)) if not os.path.isdir(mod_path): continue nuke.pluginAddPath(mod_path) self.logger.info("Added python path: {0}".format(mod_path)) self.logger.info("Finished adding python paths from: {0}\n".format( self.python_path))
def add_tool_paths(self): """ Add the paths for all plugins. """ self.logger.info("Adding plugin paths.") nuke.pluginAddPath(self.plugins_path) self.logger.info("Added root path: {0}".format(self.plugins_path)) for key in self.tools_dict: if key is None or key is u"": continue tool_path = self.plugins_path + "/" + key if not os.path.isdir(tool_path): continue nuke.pluginAddPath(tool_path) self.logger.info("Added tool path: {0}".format(tool_path)) self.logger.info("Finished adding tool paths from: {0}\n".format( self.plugins_path))
def post_app_init(self): """ Called when all apps have initialized """ # render the menu! if self._ui_enabled: # note! not using the import as this confuses nuke's calback system # (several of the key scene callbacks are in the main init file...) import tk_nuke menu_name = "Shotgun" if self.get_setting("use_sgtk_as_menu_name", False): menu_name = "Sgtk" # create menu self._menu_generator = tk_nuke.MenuGenerator(self, menu_name) self._menu_generator.create_menu() # initialize favourite dirs in the file open/file save dialogs self.__setup_favorite_dirs() # register all panels with nuke's callback system # this will be used at nuke startup in order # for nuke to be able to restore panels # automatically. For all panels that exist as # part of saved layouts, nuke will look through # a global list of registered panels, try to locate # the one it needs and then run the callback for (panel_id, panel_dict) in self.panels.iteritems(): nukescripts.panels.registerPanel(panel_id, panel_dict["callback"]) # iterate over all apps, if there is a gizmo folder, add it to nuke path for app in self.apps.values(): # add gizmo to nuke path app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # now translate the path so that nuke is happy on windows app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.log_debug("Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH" % app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # and also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder)
def main(): Log = _DebugPrint('nkstCC_init.main') # Python Scripts locations exeDir = os.path.dirname(__file__) # preferably ~/.nuke rscDirname = "nkstCC_resources" rscDir = os.path.join( exeDir,rscDirname ) # resources if not os.path.exists(rscDir): Log.msg("Can't find %s in %s.\nMake sure you have copied it and try again."%(rscDirname,exeDir)) return # Add nkstCC_resources folder to nuke paths nuke.pluginAddPath(rscDir) # Nuke Studio Script nkstSN = "nkstCC_nkst.py" nkstSP = os.path.join(rscDir,nkstSN) # Nuke Script nukeSN = "nkstCC_nuke.py" nukeSP = os.path.join(rscDir,nukeSN) # Commandline Script cmdlSN = "nkstCC_cmd.py" cmdlSP = os.path.join(rscDir,cmdlSN) # Check nuke mode and assign script to run exeScriptPath = nkstSP if nuke.env['studio'] else nukeSP # Cancel if python script not found if not os.path.exists(exeScriptPath): msg = "Can't find the script file at %s"%(exeScriptPath) Log.msg(msg) nuke.message(msg) return import nkstCC_nkst import nkstCC_nuke # Launch exescript if nuke.env['studio']: Log.msg("Mode: nkst") nkstCC_nkst.main(cmdlSP) else: Log.msg("Mode: nuke") nkstCC_nuke.main()
def post_app_init_nuke(self, menu_name="Shotgun"): """ The Nuke-specific portion of the engine's post-init process. """ if self.has_ui: # Note! not using the import as this confuses Nuke's callback system # (several of the key scene callbacks are in the main init file). import tk_nuke # Create the menu! self._menu_generator = tk_nuke.NukeMenuGenerator(self, menu_name) self._menu_generator.create_menu() # Initialize favourite dirs in the file open/file save dialogs self.__setup_favorite_dirs() # Register all panels with nuke's callback system # this will be used at nuke startup in order # for nuke to be able to restore panels # automatically. For all panels that exist as # part of saved layouts, nuke will look through # a global list of registered panels, try to locate # the one it needs and then run the callback. for (panel_id, panel_dict) in self.panels.iteritems(): nukescripts.panels.registerPanel( panel_id, panel_dict["callback"], ) # Iterate over all apps, if there is a gizmo folder, add it to nuke path. for app in self.apps.values(): # Add gizmos to nuke path. app_gizmo_folder = os.path.join(app.disk_location, "gizmos") if os.path.exists(app_gizmo_folder): # Now translate the path so that nuke is happy on Windows. app_gizmo_folder = app_gizmo_folder.replace(os.path.sep, "/") self.log_debug( "Gizmos found - Adding %s to nuke.pluginAddPath() and NUKE_PATH" % app_gizmo_folder) nuke.pluginAddPath(app_gizmo_folder) # And also add it to the plugin path - this is so that any # new processes spawned from this one will have access too. # (for example if you do file->open or file->new) tank.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder)
def load(): supportedMagicNumbers = ['03f30d0a', 'd1f20d0a'] try: magicNumberOfThisVersion = imp.get_magic().encode('hex') if magicNumberOfThisVersion in supportedMagicNumbers: pathToThisVersion = "python/mamoworld/mochaImportPlus/version_" + magicNumberOfThisVersion nuke.pluginAddPath(pathToThisVersion) else: raise Exception( "MochaImport+ for NUKE: unsupported version of Python:" + sys.version + "(magic number:" + magicNumberOfThisVersion + ")") except Exception as e: import traceback nuke.tprint(traceback.format_exc()) # Just in case msg = 'ERROR: %s' % e if nuke.GUI: nuke.message(msg) else: nuke.tprint(msg)
def main(): scriptsDir=os.path.dirname(__file__) parentScriptsDir=os.path.dirname(scriptsDir) cacheManagerDir=parentScriptsDir+'/mlCacheManager' #del sys.modules['shotManager'] sys.path.append(cacheManagerDir) from nukescripts import panels nuke.pluginAddPath(cacheManagerDir) import cacheManager reload(cacheManager) from cacheManager import NukeTestWindow win=panels.registerWidgetAsPanel('cacheManager.NukeTestWindow', 'cacheManager', 'farts', True) pane = nuke.getPaneFor('Properties.1') #pane = nuke.getPaneFor('DAG.1') #win.show() win.addToPane(pane)
def load(): supportedMagicNumbers = ['03f30d0a', 'd1f20d0a'] try: magicNumberOfThisVersion = imp.get_magic().encode('hex') if magicNumberOfThisVersion in supportedMagicNumbers: pathToThisVersion = "./version_" + magicNumberOfThisVersion nuke.pluginAddPath(pathToThisVersion) else: raise Exception("MochaImport+ for NUKE: unsupported version of Python:" + sys.version + "(magic number:" + magicNumberOfThisVersion + ")") except Exception as e: import traceback nuke.tprint(traceback.format_exc()) # Just in case msg = 'ERROR: %s' % e if nuke.GUI: nuke.message(msg) else: nuke.tprint(msg)
def load_nuke_env(self): """Loads all sequence and shot plugin paths. Validates the plugins are there, if not displays warning using nuke.message """ sequence, shot = self.session.get_core_session() # show based plugins and templates since not in shot envir if sequence == "show": # check that plugin paths exist if not os.path.exists(self.ani_vars.plugin_show): nuke.message("Could not load show plugins {0}. Please check they exist. If not see Installing Show " "Nuke Plugins and Templates on Confluence to add them.".format(self.ani_vars.plugin_show)) return if not os.path.exists(self.ani_vars.templates_show): nuke.message("Could not load show templates {0}. Please check they exist. If not see Installing Show " "Nuke Plugins and Templates on Confluence to add them.".format(self.ani_vars.templates_show)) return nuke.pluginAddPath(self.ani_vars.plugin_show) nuke.pluginAddPath(self.ani_vars.templates_show) # sequence and shot based plugins since in shot envir else: # do this first, update func needs this set self.ani_vars.load_seq_shot_list() self.ani_vars.update(sequence, shot) # check that plugin paths exist if not os.path.exists(self.ani_vars.plugin_seq): nuke.message("Could not load seq: {0} plugins path: {1}. Please see Production Team > Tools > Py Ani " "Tools > PyNukeMngr on Confluence to add them".format(sequence, self.ani_vars.plugin_seq)) return if not os.path.exists(self.ani_vars.templates_seq): nuke.message( "Could not load seq: {0} templates path: {1}. Please see Production Team > Tools > Py Ani " "Tools > PyNukeMngr on Confluence to add them".format(sequence, self.ani_vars.templates_seq) ) return nuke.pluginAddPath(self.ani_vars.shot_comp_plugin_dir) nuke.pluginAddPath(self.ani_vars.plugin_seq) nuke.pluginAddPath(self.ani_vars.templates_seq) logging.info("Plugin Paths: {0}".format(nuke.pluginPath()))
def main(): shotManagerDir = os.path.dirname(mlTools.__file__).replace( "\\", "/") + '/mlShotManager' #del sys.modules['shotManager'] sys.path.append(shotManagerDir) from nukescripts import panels nuke.pluginAddPath(shotManagerDir) from mlTools.mlShotManager import shotManager reload(shotManager) from shotManager import shotManagerWindow win = panels.registerWidgetAsPanel( 'mlTools.mlShotManager.shotManager.shotManagerWindow', 'shotManager', 'farts', True) pane = nuke.getPaneFor('Viewer.1') #pane = nuke.getPaneFor('Properties.1') #pane = nuke.getPaneFor('DAG.1') #win.show() win.addToPane(pane)
def NukeDo(MosesObject=Moses(host='10.0.0.135')): import nuke import sys questionList = NukeQuestionFinding() if debug:print questionList question = ','.join(questionList) mosesAnswer_og = MosesObject.getAnswer(question) global mosesAnswer mosesAnswer = NukeAnalysis(mosesAnswer_og) #old #sys.path.append(syspath) #nuke.pluginAddPath(syspath) #new global syspath syspath = chkupdate(mosesAnswer, questionList) if debug:print 'syspath',syspath sys.path.append(syspath) nuke.pluginAddPath(syspath)
def groupToGizmo(): grp= nuke.thisGroup() stamp=str(datetime.datetime.now()).split(".")[0].replace("-","_").replace(":","_") filePath = nuke.getFilename('select Gizmo File to update', '*.gizmo') fileName=filePath.split("/")[-1] dir = os.path.dirname( filePath ) try: newDir= dir+'/_backup/'+stamp os.makedirs(newDir) except: pass shutil.move(filePath,newDir+'/'+fileName) os.rename(newDir+'/'+fileName,newDir+'/'+fileName.replace("gizmo","gizno")) n=nuke.selectedNode().setName(fileName.split('.')[0]) nuke.nodeCopy(filePath) fileObject=open(filePath,"r") contents=fileObject.read() fileObject.close() newContents='' for line in contents.split('\n'): line=line.replace('Group {','Gizmo {') if not "cut_paste_input" in line: if not "version" in line: if not "selected" in line: newContents+=line+'\n' fileObject=open(filePath,"w") fileObject.write(newContents) fileObject.close() nuke.pluginAddPath(dir) n=nuke.selectedNode() c =nuke.createNode(fileName.split(".")[0]) #c['tile_color'].setValue(16711935) replaceNode(n,c,grp) c.setName(fileName.split(".")[0])
def main(): scriptsDir = os.path.dirname(__file__) parentScriptsDir = os.path.dirname(scriptsDir) autoCompDir = parentScriptsDir + '/mlAutoComp' sys.path.append(autoCompDir) from nukescripts import panels nuke.pluginAddPath(autoCompDir) import autoComp reload(autoComp) from autoComp import nukeAutoCompWindow win = panels.registerWidgetAsPanel('autoComp.nukeAutoCompWindow', 'autoComp', 'farts', True) pane = nuke.getPaneFor('Viewer.1') #pane = nuke.getPaneFor('Properties.1') #pane = nuke.getPaneFor('DAG.1') #win.show() win.addToPane(pane)
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.")
# init.py # J_Ops # # Created by Jack Binks on 14/02/2010. # Copyright (c) 2010 Jack Binks. All rights reserved. import sys, nuke, os for path in nuke.pluginPath(): if os.path.exists(os.path.normpath(path+"/J_Ops/py")): sys.path.append(path+"/J_Ops/py") if os.path.exists(os.path.normpath(path+"/../J_Ops/py")): sys.path.append(path+"/py") if os.path.exists(os.path.normpath(path+"/../J_Ops/ndk")): nuke.pluginAddPath(path+"/ndk") if os.path.exists(os.path.normpath(path+"/../J_Ops/icons")): nuke.pluginAddPath(path+"/icons")
# Copyright (c) 2009 The Foundry Visionmongers Ltd. All Rights Reserved. ## init.py ## loaded by nuke before menu.py import sys import nuke from scripts import slate from scripts import ftrackUpload from scripts import writeNodeManager from scripts import readNodeManager print "Loading init.py...." nuke.pluginAddPath('./gizmos') nuke.pluginAddPath('./icons')
import nuke import os import sys import re nuke.tprint('running init.py') homepath = os.path.abspath('/nas/projects/development/pipeline/pipeline.config/nuke_repo') targetDirs = [os.path.join(homepath, dir) for dir in os.listdir(homepath) if os.path.isdir(os.path.join(homepath, dir))] nukePattern = re.compile('nuke\.([A-Z]+)$') sysPattern = re.compile('sys\.([A-Z]+)$') for i in targetDirs: thisDir = os.path.split(i)[1] if nukePattern.match(thisDir): nuke.pluginAddPath(i) if sysPattern.match(thisDir): sys.path.append(i) if not nuke.GUI: nuke.tprint('\n\n') for i in nuke.pluginPath(): nuke.tprint(i) nuke.tprint('\n\n') for i in sys.path: nuke.tprint(i) nuke.tprint('\n\n') nuke.ViewerProcess.register("3D LUT", nuke.createNode, ("Vectorfield", "vfield_file /nas/projects/development/pipeline/pipeline.config/nuke_repo/nuke.LUT/logC-Filmlook_display/AlexaV3_EI1600_LogC2Film_EL_nuke3d.cube"))
import nuke import os import inspect import fxpipe ''' This will add all subdirectories here to the Nuke Path ''' curInitFile = inspect.getfile(inspect.currentframe()) # get location of current py file fileDir = os.path.dirname(curInitFile) # get the dir name of that file for (path, dirs, files) in os.walk('%s' % (fileDir)): if fxpipe.os in path: nuke.pluginAddPath(path) # add to the nuke plugin path for each directory found
import nuke nuke.pluginAddPath("./plugins")
import nuke # Add subfolders to path to make this a little cleaner nuke.pluginAddPath( './gizmos' ) nuke.pluginAddPath( './python' ) nuke.pluginAddPath( './plugins' )
# Script Name: init # Version: 1.0 # Purpose: Adding plugin paths for Pr_Suite. # Created For: Pr_Suite v1.0 # Created On: 5/10/2015 # Author: Parimal Desai # Website: www.parimalvfx.com # History: v1.0 (5/10/2015) # Pr_Suite plugin paths. import nuke nuke.pluginAddPath("./gizmos") nuke.pluginAddPath("./python") nuke.pluginAddPath("./python/PrPy") nuke.pluginAddPath("./icons") nuke.pluginAddPath("./documentation")
import nuke import fxpipe import fxpipenukescripts import os ''' The template for the nuke setup Make sure to configure this file so that you get the show specific things loaded in ''' ### CUSTOMIZE HERE nuke.pluginAddPath(os.path.join(fxpipe.jobPath, fxpipe.job, fxpipe.jobPathNuke)) ### END CUSTOMIZE ### NO Fiddling past here generally nuke.pluginAddPath('./gizmos') ### Add general formats here nuke.load('formats.py') ### Make sure we create write directories automatically nuke.addBeforeRender(fxpipenukescripts.createWriteDir)
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 regPath(x, dirname, filenames): # if 'init.py' in filenames: nuke.pluginAddPath(dirname) print os.path.basename(dirname), '...'
def __init__(self): nuke.pluginAddPath(os.path.join(_c.MYNK_PATH, 'icons'), addToSysPath=False) LOG.info(' [MyNk] initializing custom user menus etc.')
# 256 pipeline tools # Add custom plugin paths # Set knob defaults # Set custom format import nuke, os # Get project root (P:/FUTURAMA/) rootProject = os.path.dirname(__file__).split('PREP/PIPELINE/DNA/2D')[0] # Set Path to GIZMOS gizmo = '{}PREP/PIPELINE/DNA/2D/gizmo'.format(rootProject) nuke.pluginAddPath(gizmo, addToSysPath = False) # Set paths DNA to scripts python = '{}PREP/PIPELINE/DNA/2D/scripts/'.format(rootProject) sys.path.append(python) # Set FORMAT nuke.addFormat('1998 1080 1.0 KZMRES') nuke.knobDefault('Root.format', 'KZMRES')
# Import built-in modules. import os.path as os_path # Import Nuke modules. import nuke # Add current package to nuke plugin path. nuke.pluginAddPath( os_path.join(os_path.dirname(__file__), 'nuke_to_archive', 'icons')) toolbar = nuke.menu("Nodes") hz_main_node = toolbar.addCommand( 'Nuke To archive', "import nuke_to_archive;nuke_to_archive.archive()", icon="nuke_to_archive.png")
import nuke #PLUGIN PATHS nuke.pluginAddPath('./gizmos') nuke.pluginAddPath('./python') nuke.pluginAddPath('./tcl') nuke.pluginAddPath('./icons') nuke.pluginAddPath('./lib') nuke.pluginAddPath('./lut') import os, nukescripts, platform import pipeline import sendToAvconv # SET KNOB DEFAULTS # //////////////////////////////////////////////////////////////////////////////// # WRITE NODE # use this instead of nuke.addBeforeRender so that artists can remove it locally if needed nuke.knobDefault('Write.beforeRender', 'pipeline.createWriteDir()') nuke.knobDefault('Write.afterRender', 'sendToAvconv.sendToAvconv()') # ROOT nuke.knobDefault('Root.project_directory', '[python {nuke.script_directory()}]/../') nuke.knobDefault('Root.format', 'HD') nuke.knobDefault('Root.proxy_type', 'scale') nuke.knobDefault('Root.proxy_scale', '.5') nuke.knobDefault('Root.fps', '23.976') # NODE PRESETS # ////////////////////////////////////////////////////////////////////////////////
# -*- coding=UTF-8 -*- import nuke nuke.pluginAddPath('Tangent_Space_Normals')
#coding:utf-8 import nuke, os #插件路径的不确定性,没法使用固定路径,只能全部添加 dir_list = ["gizmos", "Channel" ] #要添加的文件夹,暂时只知道这2个里面有gizmo节点,需要添加的pluginpath里,其他的路径还为发现错误 for nukepath in nuke.pluginPath(): for dir in dir_list: file_path = "{}/{}".format(nukepath, dir) if os.path.isdir(file_path): for root, dirs, files in os.walk(file_path): for dir in dirs: dirpath = "{}/{}".format(file_path, dir) if not dirpath in nuke.pluginPath(): nuke.pluginAddPath(dirpath)
__author__ = 'Alex Schworer' __copyright__ = 'Copyright 2011, Atomic Fiction, Inc.' config_path = '%s/config_nuke.py' % (os.path.dirname(__file__),) if not os.path.exists(config_path): raise Exception('Could not locate config_nuke.py, please create.') from config_nuke import * required_config = ['API_DIR', 'API_KEY'] for key in required_config: if not key in globals(): raise Exception('config_nuke.py must define a value for %s.' % (key,)) nuke.pluginAddPath(API_DIR) import zync # Try to connect to ZYNC. If we can't that's fine for now, we'll try # again later when the user tries to launch a job. try: ZYNC = zync.Zync('nuke_plugin', API_KEY) except: ZYNC = None def generate_script_path(extra_name=None): """ Returns a hash-embedded script path with /cloud_submit/ at the end of the path, for separation from user nuke scripts. """ script_path = nuke.root().knob('name').getValue()
#Set menu.py path #------------------------------------------------------------------ try: #NUKE_MENU_PATH nuke.pluginAddPath(NUKE_MENU_PATH) #SuccessMsg print('Successfully set Helga menu.py path: {0}'.format(NUKE_MENU_PATH)) except: #FailMsg print('Error setting Helga menu.py path: {0}'.format(NUKE_MENU_PATH))
def __init__(self): self.config = config.nuke_config """ add folder path """ base_dir = os.path.dirname(__file__) self.libs_dir = self.replace_path(os.path.join(base_dir, "libs")) self.luts_dir = self.replace_path(os.path.join(base_dir, "luts")) self.python_dir = self.replace_path(os.path.join(base_dir, "python")) self.template_dir = self.replace_path(os.path.join(base_dir, "template")) """ append system path """ if not self.python_dir in sys.path: sys.path.append(self.python_dir) """ add gizmos path """ self.gizmos_image_dir = self.replace_path(os.path.join(base_dir, "gizmos/Image")) self.gizmos_Filter_dir = self.replace_path(os.path.join(base_dir, "gizmos/Filter")) self.gizmos_channel_dir = self.replace_path(os.path.join(base_dir, "gizmos/Channel")) self.gizmos_Lighting_dir = self.replace_path(os.path.join(base_dir, "gizmos/Lighting")) self.gizmos_3D_dir = self.replace_path(os.path.join(base_dir, "gizmos/3D")) self.gizmos_Keyer_dir = self.replace_path(os.path.join(base_dir, "gizmos/Keyer")) self.gizmos_ToolSet_dir = self.replace_path(os.path.join(base_dir, "gizmos/ToolSet")) self.gizmos_3D_Tangent_dir = self.replace_path(os.path.join(base_dir, "gizmos/3D/Tangent_Space_Normals")) nuke.pluginAddPath(self.gizmos_image_dir) nuke.pluginAddPath(self.gizmos_channel_dir) nuke.pluginAddPath(self.gizmos_Filter_dir) nuke.pluginAddPath(self.gizmos_Lighting_dir) nuke.pluginAddPath(self.gizmos_3D_dir) nuke.pluginAddPath(self.gizmos_Keyer_dir) nuke.pluginAddPath(self.gizmos_ToolSet_dir) nuke.pluginAddPath(self.gizmos_3D_Tangent_dir) """ add icons path """ self.icons_menu_dir = self.replace_path(os.path.join(base_dir, "icons/icon_menu")) self.icons_toolbar_dir = self.replace_path(os.path.join(base_dir, "icons/icon_toolbar")) self.icons_item_dir = self.replace_path(os.path.join(base_dir, "icons/icon_item")) nuke.pluginAddPath(self.icons_menu_dir) nuke.pluginAddPath(self.icons_toolbar_dir) nuke.pluginAddPath(self.icons_item_dir)
#创建路径 #20171213 import nuke nuke.pluginAddPath('//192.168.0.2/PythonDev/BC_ToolSet') nuke.pluginAddPath('//192.168.0.2/PythonDev/NukeToolSet') nuke.pluginAddPath('//192.168.0.2/PythonDev/Pr_Suite') nuke.pluginAddPath('//192.168.0.2/PythonDev/PLUS1.0_Beta') nuke.pluginAddPath('//192.168.0.2/PythonDev/Distortion')
''' Created on 07.08.2011 @author: jonas thorbruegge ([email protected]) ''' import nuke, os, sys nuke.pluginAddPath(os.path.dirname(__file__)) class sojus(): def __init__(self): #nuke.pluginAddPath(os.path.dirname(__file__)) self.setNodeDefaults() self.setPresets() self.buildNukeMenu() self.buildNodeMenu() 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")
"""Adds custom nodes, plugins, and tools to the menus. """ import nuke import viewer_util import node_util import settings from gizmo_util import GizmoLibrary # default menu icon for all non-vanilla nuke menu items nuke.pluginAddPath('./icons') DEFAULT_MENU_ICON = 'cb_icon.png' # define menu locations nuke_menu = nuke.menu('Nuke') node_menu = nuke.menu('Nodes') toolsets_menu = node_menu.findItem('ToolSets') cb_menu = nuke_menu.addMenu('ChickenBone') # checks nuke version because they changed the name of recent files in menu if nuke.NUKE_VERSION_MAJOR < 9: recent_menu_item = "_&Recent Files" else: recent_menu_item = "Open Recent Comp" def install(): """Adds custom menu items""" # Appends more recent files to recent file menu. By deafult nuke only shows last 6 files for i in range(7, 10): nuke_menu.addCommand(
import os import nuke import pynk nuke.pluginAddPath("./icons", addToSysPath = False) #nuke.pluginAddPath("C:/workshop/PillarsAssetMG2/Nuke") PillarsMenu = nuke.menu('Nodes').addMenu('Pillars', icon = "pillars.png") PillarsMenu.addCommand('GammaMan Creater', 'pynk.gammaMan()') PillarsMenu.addCommand('GammaMan Writer', 'pynk.writeGammaMan()') PillarsMenu.addCommand('File Replacer', 'pynk.fileReplaceMan()') PillarsMenu.addCommand('Update', 'reload(pynk)') PillarsZHQMenu = PillarsMenu.addMenu('ZHQ') PillarsZHQMenu.addCommand('ZHQ Bezier', "nuke.createNode('Bezier')") PillarsZHQMenu.addCommand('ZHQ Color Copy', "nuke.createNode('zhq_ColorCopy')") PillarsZHQMenu.addCommand('ZHQ Control Channel', "nuke.createNode('zhq_control_channel')") PillarsZHQMenu.addCommand('ZHQ Deep', "nuke.createNode('zhq_deep')") PillarsZHQMenu.addCommand('ZHQ Displace', "nuke.createNode('zhq_Displace')") PillarsZHQMenu.addCommand('ZHQ Merge', "nuke.createNode('zhq_Merge')") PillarsZHQMenu.addCommand('ZHQ N', "nuke.createNode('zhq_N')") PillarsZHQMenu.addCommand('ZHQ Normal', "nuke.createNode('zhq_normal')") PillarsZHQMenu.addCommand('ZHQ P_N', "nuke.createNode('zhq_P_N')") PillarsZHQMenu.addCommand('ZHQ RGB Choose', "nuke.createNode('zhq_RGB_choose')") PillarsZHQMenu.addCommand('ZHQ Shuffle_P', "nuke.createNode('zhq_shuffle_P')") PillarsZHQMenu.addCommand('ZHQ Shuffle_smoke', "nuke.createNode('zhq_shuffle_smoke')") PillarsZHQMenu.addCommand('ZHQ Shuffle_TD', "nuke.createNode('zhq_shuffle_TD')") PillarsZHQMenu.addCommand('ZHQ Slate', "nuke.createNode('zhq_slate')")