def sb_listExternalNodes(): # Nuke Path. nukeDir = os.path.dirname(nuke.env['ExecutablePath']) # Get loaded plugs/gizmos. p = nuke.plugins(0, '*.ofx', '*.%s' % nuke.PLUGIN_EXT) g = nuke.plugins(0, '*.gizmo') loadedPlugs = [] loadedGizmos = [] for i in p: if not i.startswith(nukeDir): pName = os.path.splitext(i.replace("\\", "/").split("/")[-1])[0] # Special case for Neat Video. if pName == "NeatVideo": pName = "OFXcom.absoft.neatvideo_v2" loadedPlugs.append(pName) for i in g: if not i.startswith(nukeDir): gName = os.path.splitext(i.replace("\\", "/").split("/")[-1])[0] loadedGizmos.append(gName) # See which of the loaded nodes are currently used. externalPlugins = [] externalGizmos = [] with nuke.root(): for i in nuke.allNodes(recurseGroups=True): if i.Class() in loadedPlugs: if not i.Class() in externalPlugins: externalPlugins.append(i.Class()) elif i.Class() in loadedGizmos: if not i.Class() in externalGizmos: externalGizmos.append(i.Class()) # Format strings. gizmoStr = "\n".join( sorted(externalGizmos, key=lambda s: s.lower()) ) plugStr = "\n".join( sorted(externalPlugins, key=lambda s: s.lower()) ) externalNodes = "<b>sb ListExternalNodes</b>\n\nA list of external nodes used in current script.\n\n<b>Gizmos:</b>\n{0}\n\n<b>Plug-ins:</b>\n{1}\n\nNote that OFX plug-ins might not be listed.".format(gizmoStr, plugStr) # Print info. if nuke.GUI: lines = externalNodes.split("\n") if len(lines) > 125: longMessage("info", externalNodes) else: nuke.message(externalNodes) else: print externalNodes
def ocio_populate_menu(): """Adds OCIO nodes to a menu in Color """ m_nodes = nuke.toolbar('Nodes') m_color = m_nodes.findItem("Color") m_ocio = m_color.addMenu("OCIO", icon="ocio_icon.png") allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for fname in allplugs: nodeMenu = nodeClass = os.path.splitext(fname)[ 0] # strip .so extension # Put a space after "OCIO" to match The Foundry's convention (huh?) if nodeMenu.startswith("OCIO"): nodeMenu = nodeMenu.replace("OCIO", "OCIO ", 1) # Only add the item if it doesn't exist if not m_ocio.findItem(nodeMenu): m_ocio.addCommand( nodeMenu, lambda nodeClass=nodeClass: nuke.createNode(nodeClass)) m_utils = m_ocio.addMenu("Utils") m_utils.addCommand("Import .ccc to CDL nodes", ocionuke.cdl.import_multiple_from_ccc) m_utils.addCommand("Export selected CDL's to .ccc", ocionuke.cdl.export_multiple_to_ccc)
def _get_caravr_version(): """Returns CaraVR version, if present or empty string otherwise. To discover CaraVR we use plugin path list, which should contain a record of the form: '/Library/Application Support/Nuke/10.0/plugins/CaraVR/1.0/ToolSets/CaraVR' (OSX) 'C:\\Program Files\\Common Files/Nuke/11.0/plugins\\CaraVR\\1.0\\ToolSets/CaraVR' (Windows) We take path apart from the right until we encounter "ToolSet" component and the one preceding it is considered to be a version. This has been offered as a canonical way by The Foundry Support. """ cara_plugins = nuke.plugins(nuke.ALL, 'CaraVR') for cara_plugin in cara_plugins: if 'toolsets' in cara_plugin.lower(): remaining_path = cara_plugin.lower() last_folder_name = '' while remaining_path: remaining_path, folder_name = os.path.split(remaining_path) if last_folder_name == 'toolsets': return folder_name last_folder_name = folder_name return None
def nfxMenu(menu='NFX', panel='Nodes'): ''' Adds NFXPlugins to the menu in panel. ''' pluginList = [] plugins = nuke.plugins(nuke.ALL | nuke.NODIR, 'N_*.py', 'N_*.so', 'N_*.dylib', 'N_*.dll') for i in plugins: (root, ext) = os.path.splitext(i) if root is None or len(root) == 0: continue pluginList.append(root) if pluginList: pluginList.sort() m = nuke.menu(panel) if not m: raise RuntimeError, 'nfxMenu() argument 2 not found' for n in pluginList: m.addCommand(menu + '/' + n[2:], 'nuke.createNode("%s")' % n)
def get_plugins(): ''' TODO:(lws) WIP - there has to be better way of doing this. Return the plugins from the current Nuke session. This is a list of filepaths to each nuke plugin. ugly ['/home/nuke/tools/customCG_Neutralize.gizmo', '/home/nuke/tools/customCG_deNeutralize.gizmo', '/home/nuke/tools/customCameraShake.gizmo', '/home/nuke/tools/customChromaticAbberation.gizmo', '/home/nuke/tools/customGlint.gizmo', '/home/nuke/tools/customGrain.gizmo', '/home/nuke/tools/customHaze.gizmo', '/home/nuke/tools/custom_OutputCrop.gizmo', '/home/nuke/tools/gizmos/default_viewer.gizmo', '/home/nuke/tools/nuke/init.py', '/home/nuke/nuke/linux64/Nuke9.0/GeoPoints.so', '/home/nuke/nuke/linux64/Nuke9.0/LD_3DE4_Anamorphic_Degree_6.so', '/home/nuke/nuke/linux64/Nuke9.0/OpticalFlares.so', '/home/nuke/nuke/linux64/Nuke9.0/pgBokeh.so', '/home/nuke/nuke/linux64/Nuke9.0/render', '/home/nuke/nuke/linux64/Nuke9.0/starpro.key', '/home/nuke/.nuke/MTTF', '/home/nuke/.nuke/ScriptEditorHistory.xml', '/home/nuke/.nuke/layout1.xml', '/home/nuke/.nuke/preferences8.0.nk', '/home/nuke/.nuke/recent_files', '/home/nuke/.nuke/uistate.ini', '/home/nuke/.nuke/user.9-0.hrox', '/home/neatvideo/neat_video_ofx/NeatVideo.ofx.bundle/Contents/Linux-x86-64/NeatVideo.ofx'] ''' # If you don't specify the nuke.ALL flag, you end up with paths to icon files # (png, etg), instead of the actual plugin (.so, .py, etc). However, when specifying # nuke.ALL it also returns plugins that are not currently loaded, which we # probably don't want. I assume we want to only return plugins that are # currently in use, otherwise our docker image requirements become far more # comprehensive (demanding) than they need to be. So we use the # nuke.pluginExists() on each plugin, to determine if the plugin is loaded. # I have no idea if the this is a the best way (or even a reliable way) to # determine if a plugin is loaded or not, but I couldn't find a better function. # It did however cut down the returned plugins by 10 (54 to 44). # Note that we gather the fullpaths bc it's possible that there could be # naming conflicts/overlaps between plugins. # Exclude any plugins that are located within Nuke's installation directory. # We'll assume those are standarad plugins that Nuke ships with. Perhaps # a bad assumption, but we'll go with it for now. plugins = [] nuke_dirpath = os.path.dirname(nuke.EXE_PATH) for p in nuke.plugins(nuke.ALL): if nuke.pluginExists(p) and not p.startswith(nuke_dirpath): plugins.append(p) return plugins
def ocio_populate_menu(): """Adds OCIO nodes to a menu in Color """ m_nodes = nuke.toolbar('Nodes') m_color = m_nodes.findItem("Color") m_ocio = m_color.addMenu("OCIO", icon = "ocio_icon.png") allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for fname in allplugs: p = os.path.splitext(fname)[0] # strip .so extension m_ocio.addCommand(p, lambda p=p: nuke.createNode(p))
def update_plugin_menu(menuname): list = [] if nuke.env['nc']: plugins = nuke.plugins(nuke.ALL | nuke.NODIR, "*." + nuke.PLUGIN_EXT, "*.ofx.bundle", "*.gizmo", "*.gznc") else: plugins = nuke.plugins(nuke.ALL | nuke.NODIR, "*." + nuke.PLUGIN_EXT, "*.ofx.bundle", "*.gizmo") for i in plugins: (root, ext) = os.path.splitext(i) (root, ext) = os.path.splitext(root) # Sometimes we get files like ._Glare.gizmo, etc due to Mac OS X # or editors and that returns an empty string for root. if root is None or len(root) == 0: continue if not root[0] == '@': list.append(root) n = nuke.menu("Nodes").addMenu("Other/" + menuname) list.sort() for i in list: s = i.upper() p = n.addMenu(s[0]) p.addCommand(i, "nuke.createNode('" + i + "')")
def ocio_populate_menu(): """Adds OCIO nodes to a menu in Color """ m_nodes = nuke.toolbar('Nodes') m_color = m_nodes.findItem("Color") m_ocio = m_color.addMenu("OCIO", icon="ocio_icon.png") allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for fname in allplugs: p = os.path.splitext(fname)[0] # strip .so extension m_ocio.addCommand(p, lambda p=p: nuke.createNode(p))
def ocio_populate_menu(): """Adds OCIO nodes to a menu in Color """ m_nodes = nuke.toolbar('Nodes') m_color = m_nodes.findItem("Color") m_ocio = m_color.addMenu("OCIO", icon = "ocio_icon.png") allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for fname in allplugs: p = os.path.splitext(fname)[0] # strip .so extension m_ocio.addCommand(p, lambda p=p: nuke.createNode(p)) m_utils = m_ocio.addMenu("Utils") m_utils.addCommand("Import .ccc to CDL nodes", ocionuke.cdl.import_multiple_from_ccc) m_utils.addCommand("Export selected CDL's to .ccc", ocionuke.cdl.export_multiple_to_ccc)
def ocio_populate_menu(): """Adds OCIO nodes to a menu in Color """ m_nodes = nuke.toolbar('Nodes') m_color = m_nodes.findItem("Color") m_ocio = m_color.addMenu("OCIO", icon="ocio_icon.png") allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for fname in allplugs: p = os.path.splitext(fname)[0] # strip .so extension m_ocio.addCommand(p, lambda p=p: nuke.createNode(p)) m_utils = m_ocio.addMenu("Utils") m_utils.addCommand("Import .ccc to CDL nodes", ocionuke.cdl.import_multiple_from_ccc) m_utils.addCommand("Export selected CDL's to .ccc", ocionuke.cdl.export_multiple_to_ccc)
def load_all_plugins(): tried = 0 failed = 0 p = nuke.plugins(nuke.ALL, "*." + nuke.PLUGIN_EXT) for i in p: # Ignore Alembic_In, since it isn't a nuke plugin. # TODO - Needs to be moved a directory up so it doesn't show as a nuke plugin if i.find("Alembic_In") != -1: continue tried += 1 print i try: try_load = nuke.load(i) except: print i, "failed to load." failed += 1 if failed > 0: print failed, "of", tried, "plugin(s) total did not load" else: print "All available binary plugins (", tried, ") successfully loaded"
def ocio_populate_menu(): """Adds OCIO nodes to a menu in Color """ m_nodes = nuke.toolbar('Nodes') m_color = m_nodes.findItem("Color") m_ocio = m_color.addMenu("OCIO", icon = "ocio_icon.png") allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for fname in allplugs: nodeMenu = nodeClass = os.path.splitext(fname)[0] # strip .so extension # Put a space after "OCIO" to match The Foundry's convention (huh?) if nodeMenu.startswith("OCIO"): nodeMenu = nodeMenu.replace("OCIO", "OCIO ", 1) # Only add the item if it doesn't exist if not m_ocio.findItem(nodeMenu): m_ocio.addCommand(nodeMenu, lambda nodeClass=nodeClass: nuke.createNode(nodeClass)) m_utils = m_ocio.addMenu("Utils") m_utils.addCommand("Import .ccc to CDL nodes", ocionuke.cdl.import_multiple_from_ccc) m_utils.addCommand("Export selected CDL's to .ccc", ocionuke.cdl.export_multiple_to_ccc)
import nuke EBANNER = "OCIO Error: " OCIO = None def load_ocio_plugins(): """Loads the PyOpenColorIO module and the OCIO-prefixed nodes """ global OCIO try: import PyOpenColorIO as OCIO except Exception, e: print '%s%s\n%s' % (EBANNER, 'Loading OCIO python module', e) allplugs = nuke.plugins(nuke.ALL | nuke.NODIR, "OCIO*.so", "OCIO*.dylib", "OCIO*.dll") for p in allplugs: try: nuke.load(p) except Exception, e: print '%sLoading OCIO node %s\n%s' % (EBANNER, p, e) if __name__ == "__main__": load_ocio_plugins()