### Call Multi-View Setup Function with Custom Colors Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/stereo.html Demonstrates calling the `setUpMultiView` function with custom RGB color values for the 'left' and 'right' views, allowing for specific color assignments beyond the defaults. This example sets 'left' to red and 'right' to green. ```python setUpMultiView([ ('left', (1,0,0)), ('right', (0,1,0)) ]) ``` -------------------------------- ### Add Stereo Setup Callback on Root Node Creation Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/callbacks.html Configures Nuke to automatically set up a stereo/multi-view project when the Root node is created. Requires an 'examples' module with a 'setUpMultiView' function. ```python import examples views = [('L', (0,.5,0)), ('R',(.5,0,0)), ('M',(.5,.5,0))] nuke.addOnUserCreate( examples.setUpMultiView, views, nodeClass='Root' ) ``` -------------------------------- ### PyQt QLabel Example Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/custom_panels.html A basic example of creating a QLabel widget using PyQt5. ```python from PyQt5 import QtWidgets label = QtWidgets.QLabel("Hello World") label.show() ``` -------------------------------- ### start Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.html Opens a URL or file. ```APIDOC ## start ### Description Open a URL or file. ### Parameters * `path` (str) - The URL or file path to open. ### Returns * `None` ``` -------------------------------- ### Bake Projection Setup Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_modules/nukescripts/modelbuilder.html Creates a projection setup for the current frame using input nodes for source geometry and camera. It sets up FrameHold, Project3D, and ApplyMaterial nodes, and copies the source camera. ```python def bakeProjection(mb): """Create a projection setup for the current frame.""" if mb.Class() != "ModelBuilder": return clearNodeSelection() srcCam = mb.input(1) if not srcCam: return w = mb.screenWidth() h = mb.screenHeight() src = mb.input(0) frame = nuke.frame() if (mb['textureType'].getValue() > 0): frame = mb['textureFrame'].getValue() label = '(frame ' + str(frame) + ')' srcdot = nuke.createNode('Dot','',False) srcdot.setInput(0, src) srchold = nuke.createNode('FrameHold','',False) stamp = nuke.createNode('PostageStamp','',False) project = nuke.createNode('Project3D','',False) apply = nuke.createNode('ApplyMaterial','',False) cam = copyCamera(srcCam) camhold = nuke.clone(srchold,'',False) camdot = nuke.createNode('Dot','',False) project.setInput(1, camdot) srcdot.setXYpos( int(mb.xpos() + w * 3.5), int(mb.ypos()) ) srchold.setXYpos( int(srchold.xpos()), int(srcdot.ypos() + w) ) stamp.setXYpos( int(stamp.xpos()), int(stamp.ypos() + srchold.screenHeight() + h * 2) ) cam.setXYpos( int(srchold.xpos() - w * 1.5), int(srchold.ypos() + srchold.screenHeight() / 2 - cam.screenHeight() / 2) ) camhold.setXYpos( int(cam.xpos() + cam.screenWidth() / 2 - srchold.screenWidth() / 2), int(stamp.ypos() + h) ) project.setXYpos( int(stamp.xpos()), int(stamp.ypos() + stamp.screenHeight() + h * 2) ) camdot.setXYpos( int(camdot.xpos()), int(project.ypos() + project.screenHeight() / 2 - camdot.screenHeight() / 2) ) apply.setXYpos( int(stamp.xpos()), int(apply.ypos() + w) ) srchold.knob('first_frame').setValue( frame ) srcdot.setSelected( True ) srchold.setSelected( True ) stamp.setSelected( True ) project.setSelected( True ) apply.setSelected( True ) cam.setSelected( True ) camhold.setSelected( True ) camdot.setSelected( True ) bd = nukescripts.autoBackdrop() bd['label'].setValue('Frame %d' % frame) ``` -------------------------------- ### PySide QLabel Example Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/custom_panels.html A basic example of creating a QLabel widget using PySide2, demonstrating the import change from PyQt. ```python from PySide2 import QtWidgets label = QtWidgets.QLabel("Hello World") label.show() ``` -------------------------------- ### Python Modal Dialog Example Setup Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/basics.html Initializes a Nuke GUI environment check before defining a modal dialog. This ensures dialogs are only created in a graphical context. ```python import nukescripts if nuke.env["gui"]: ``` -------------------------------- ### Implement RV as NUKE's Flipbook Application Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/flipbook.html This Python script provides an example implementation for using RV as NUKE's flipbook application. It requires modification of TODO marked sections for paths and frame range handling. Ensure RV is installed and its path is correctly specified. ```python # Copyright (c) 2010 The Foundry Visionmongers Ltd. All Rights Reserved. import nuke import nukescripts import nukescripts.flipbooking as flipbooking import os class RVFlipbook(flipbooking.FlipbookApplication): """ This is an example implementation of how to deal with implementing a flipbook application other than NUKE's Player for NUKE. This script needs to be modified in several places before it can work, so please read all of the notes marked with TODO and modify them where necessary.""" def __init__(self): # TODO: Please put your own path in here or add RV path discovery. self._rvPath = "/Applications/RV64.app/Contents/MacOS/RV64" def name(self): return "RV" def path(self): return self._rvPath def cacheDir(self): return os.environ["NUKE_TEMP_DIR"] def run(self, filename, frameRanges, views, options): # TODO: You probably want more involved handling of frame ranges! sequence_interval = str(frameRanges.minFrame())+"-"+str(frameRanges.maxFrame()) for frame in range(frameRanges.minFrame(), frameRanges.maxFrame()): if frame not in frameRanges.toFrameList(): print("This example only supports complete frame ranges.") return os.path.normpath(filename) args = [] if nuke.env['WIN32']: args.append( "\"" + self.path() + "\"" ) filename = filename.replace("/", "\\") filename = "\"" + filename + "\"" else: args.append( self.path() ) roi = options.get("roi") if roi and any(roi[i] for i in ('xywh')): args.append("-c " + str(int(roi["x"]))) for i in ('ywh'): args.append(str(int(roi[i]))) lut = options.get("lut", "") if lut == "linear-sRGB": args.append("-sRGB") elif lut == "linear-rec709": args.append('-rec709') args.append(filename) args.append(sequence_interval) # print(args) os.spawnv(os.P_NOWAITO, self.path(), args) def capabilities(self): return { 'proxyScale': False, 'crop': True, 'canPreLaunch': False, 'supportsArbitraryChannels': True, 'maximumViews' : 2, # TODO: This list is compiled from running rv with the following: # RV64 -formats | grep 'format "' | awk '{print $2}' | tr '[:space:]' ','; echo # This may differ for your platform! 'fileTypes' : ["j2k","jpt","jp2","dpx","cin","cineon","jpeg","jpg","rla","rpf","yuv","exr","openexr","sxr","tif","tiff","sm","tex","tx","tdl","shd","targa","tga","tpic","rgbe","hdr","iff","png","z","zfile","sgi","bw","rgb","rgba","*mraysubfile*","movieproc","stdinfb","aiff","aif","aifc","wav","snd","au","mov","avi","mp4","m4v","dv"] } flipbooking.register( RVFlipbook() ) nukescripts.setFlipbookDefaultOption("flipbook", "RV") ``` -------------------------------- ### Call Multi-View Setup Function with Default Settings Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/stereo.html Executes the `setUpMultiView` function using its default arguments, which configures 'left' and 'right' views with green and red colors, respectively. This is a simple way to activate the default stereo setup. ```python setUpMultiView() ``` -------------------------------- ### Asset Manager Module Setup Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/asset.html This section shows the basic setup for the assetManager module, including necessary imports and environment variable configuration for asset path resolution. ```python import nukescripts import nuke import re import os from glob import glob # SET UP EXAMPLE ENVIRONMENT os.environ['SHOW'] = 'showA' os.environ['SEQ'] = 'seq1' os.environ['SHOT'] = 'shot2' # DEFINE FACILITY ROOT def rootDir(): return '/Users/frank/Desktop/shows' ``` -------------------------------- ### Get Node Input Creation Time Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/basics.html Retrieves the input creation time metadata for a node. This example shows how to get the value for the 'input/ctime' key. ```python nuke.toNode("Read1").metadata("input/ctime") ``` -------------------------------- ### setup_toolbars Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.toolbars.html Sets up the toolbars. ```APIDOC ## setup_toolbars ### Description Sets up the toolbars. ### Function Signature `setup_toolbars()` ``` -------------------------------- ### Get All Nodes Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_modules/nukescripts/snap3d.html Retrieves all nodes starting from a specified node, defaulting to the root. ```python def allNodes(node = nuke.root()): ''' ``` -------------------------------- ### Set Up Example Environment Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/asset.html Sets environment variables for SHOW, SEQ, and SHOT to define the current working shot. This is a common practice for facilities to adjust workflows based on the project context. ```python # SET UP EXAMPLE ENVIRONMENT os.environ['SHOW'] = 'showA' os.environ['SEQ'] = 'seq1' os.environ['SHOT'] = 'shot2' ``` -------------------------------- ### Get Node Object by Name Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/basics.html Retrieve the node object for an existing node in the Node Graph by its name. For example, getting the node object for 'Blur1' and storing it in 'myblurNode'. ```python myblurNode = nuke.toNode( 'Blur1' ) ``` -------------------------------- ### QApplication Methods Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.cache.QApplication.html This section lists various static and instance methods for managing the QApplication instance, including event dispatching, styling, window management, and property setting. ```APIDOC ## Static Methods ### `_setEventDispatcher(_eventDispatcher: PySide2.QtCore.QAbstractEventDispatcher_) -> None` Sets the event dispatcher for the application. ### `_setFallbackSessionManagementEnabled(_arg__1: bool_) -> None` Enables or disables fallback session management. ### `_setFont(_arg__1: PySide2.QtGui.QFont_) -> None` Sets the default font for the application. ### `_setFont(_arg__1: PySide2.QtGui.QFont_, _className: Optional[bytes] = None_) -> None` Sets the font for a specific class within the application. ### `_setGlobalStrut(_arg__1: PySide2.QtCore.QSize_) -> None` Sets a global strut size for widgets. ### `_setHighDpiScaleFactorRoundingPolicy(_policy: PySide2.QtCore.Qt.HighDpiScaleFactorRoundingPolicy_) -> None` Sets the rounding policy for high DPI scale factors. ### `_setKeyboardInputInterval(_arg__1: int_) -> None` Sets the interval for keyboard input. ### `_setLayoutDirection(_direction: PySide2.QtCore.Qt.LayoutDirection_) -> None` Sets the layout direction for the application. ### `_setLibraryPaths(_arg__1: Sequence[str]_) -> None` Sets the library paths for the application. ### `_setOrganizationDomain(_orgDomain: str_) -> None` Sets the organization domain for the application. ### `_setOrganizationName(_orgName: str_) -> None` Sets the organization name for the application. ### `_setOverrideCursor(_arg__1: PySide2.QtGui.QCursor_) -> None` Sets an override cursor for the application. ### `_setPalette(_arg__1: PySide2.QtGui.QPalette_, _className: Optional[bytes] = None_) -> None` Sets the palette for a specific class within the application. ### `_setPalette(_pal: PySide2.QtGui.QPalette_) -> None` Sets the application's palette. ### `_setQuitLockEnabled(_enabled: bool_) -> None` Enables or disables the quit lock for the application. ### `_setQuitOnLastWindowClosed(_quit: bool_) -> None` Determines if the application should quit when the last window is closed. ### `_setSetuidAllowed(_allow: bool_) -> None` Sets whether setuid is allowed for the application. ### `_setStartDragDistance(_l: int_) -> None` Sets the distance for initiating a drag operation. ### `_setStartDragTime(_ms: int_) -> None` Sets the time for initiating a drag operation. ### `_setStyle(_arg__1: PySide2.QtWidgets.QStyle_) -> None` Sets the application's style. ### `_setStyle(_arg__1: str_) -> PySide2.QtWidgets.QStyle` Sets the application's style using a string identifier and returns the style. ### `_setWheelScrollLines(_arg__1: int_) -> None` Sets the number of lines to scroll with the wheel. ### `_setWindowIcon(_icon: PySide2.QtGui.QIcon_) -> None` Sets the application's window icon. ### `_startDragDistance() -> int` Returns the distance for initiating a drag operation. ### `_startDragTime() -> int` Returns the time for initiating a drag operation. ### `_startingUp() -> bool` Checks if the application is currently starting up. ### `_style() -> PySide2.QtWidgets.QStyle` Returns the application's current style. ### `_styleHints() -> PySide2.QtGui.QStyleHints` Returns the application's style hints. ### `_sync() -> None` Synchronizes the application's state. ### `_testAttribute(_attribute: PySide2.QtCore.Qt.ApplicationAttribute_) -> bool` Tests if a specific application attribute is set. ### `_topLevelAt(_p: PySide2.QtCore.QPoint_) -> PySide2.QtWidgets.QWidget` Returns the top-level widget at a given point. ### `_topLevelAt(_x: int_, _y: int_) -> PySide2.QtWidgets.QWidget` Returns the top-level widget at given coordinates. ### `_topLevelWidgets() -> List[PySide2.QtWidgets.QWidget]` Returns a list of all top-level widgets. ### `_topLevelWindows() -> List[PySide2.QtGui.QWindow]` Returns a list of all top-level windows. ### `_translate(_context: bytes_, _key: bytes_, _disambiguation: Optional[bytes] = None_, _n: int = -1) -> str` Translates a given string. ### `_wheelScrollLines() -> int` Returns the number of lines to scroll with the wheel. ### `_widgetAt(_p: PySide2.QtCore.QPoint_) -> PySide2.QtWidgets.QWidget` Returns the widget at a given point. ### `_widgetAt(_x: int_, _y: int_) -> PySide2.QtWidgets.QWidget` Returns the widget at given coordinates. ### `_windowIcon() -> PySide2.QtGui.QIcon` Returns the application's window icon. ## Instance Methods ### `setObjectName(_self_, _name: str_) -> None` Sets the object name for this instance. ### `setParent(_self_, _parent: PySide2.QtCore.QObject_) -> None` Sets the parent of this object. ### `setProperty(_self_, _name: bytes_, _value: Any_) -> bool` Sets a property of this object. ### `setStyleSheet(_self_, _sheet: str_) -> None` Applies a stylesheet to this widget. ### `shutdown(_self_) -> None` Shuts down the application. ### `signalsBlocked(_self_) -> bool` Checks if signals are blocked for this object. ### `startTimer(_self_, _interval: int_, _timerType: PySide2.QtCore.Qt.TimerType = PySide2.QtCore.Qt.TimerType.CoarseTimer_) -> int` Starts a timer for this object. ### `styleSheet(_self_) -> str` Returns the stylesheet applied to this widget. ### `thread(_self_) -> PySide2.QtCore.QThread` Returns the thread this object belongs to. ### `timerEvent(_self_, _event: PySide2.QtCore.QTimerEvent_) -> None` Handles timer events. ### `tr(_self_, _arg__1: bytes_, _arg__2: bytes = b'', _arg__3: int = -1) -> str` Translates a given string using the Qt translation system. ``` -------------------------------- ### start_server Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.clientserver.start_server.html Initiates a client-server connection. It can be configured with a specific host and port. ```APIDOC ## start_server ### Description Starts a client-server connection for Nuke. This function allows you to specify the host and port for the server. ### Method `start_server(_host='localhost'_, _port=50007_) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import nukescripts.clientserver nukescripts.clientserver.start_server() # or with custom host and port nukescripts.clientserver.start_server(_host='192.168.1.100'_, _port=8080_) ``` ### Response #### Success Response This function does not return a value upon successful execution. Its effect is the establishment of a server connection. #### Response Example None ``` -------------------------------- ### Getting All Knobs of a Node Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.BackdropNode.html Retrieves a list of all knobs associated with a given Nuke node, including any nameless knobs. This example shows how to get the knobs for a Blur node. ```python >>> b = nuke.nodes.Blur() >>> b.allKnobs() ``` -------------------------------- ### nuke.beforeRender Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.beforeRender.html This function is called before the rendering process starts. It can be used to perform setup tasks or modify render settings. ```APIDOC ## nuke.beforeRender() ### Description This function is called before the rendering process starts. It can be used to perform setup tasks or modify render settings. ### Signature nuke.beforeRender() ### Parameters This function does not accept any parameters. ### Returns None ``` -------------------------------- ### Initialize Mac Software Details Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_modules/nukescripts/hardwareinfo.html Maps OS version information from system_profiler output to the standard dictionary. ```python def initMacSoftware(self, itemDicts): mapping = [["os_version", gOSVersion], ``` -------------------------------- ### Get Frame Range and Views Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/custom_panels.html Prompts the user for a frame range and, in stereo setups, for the views to operate on using nuke.getFramesAndViews(). ```python ret = nuke.getFramesAndViews('get range', '1-10') ``` -------------------------------- ### Version Dialog Setup Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_modules/nukescripts/script.html Sets up a QIntValidator for a spinbox to ensure version numbers are positive integers. Configures the layout for save-as version controls. ```python # Negative versions are not allowed, so set min valid version to 1 versionValidator = QtGui.QIntValidator() versionValidator.setBottom(1) self._saveAsVersionSpin.lineEdit().setValidator(versionValidator) saveAsVerionLayout = QtWidgets.QHBoxLayout() saveAsVerionLayout.setSpacing(0) saveAsVerionLayout.setContentsMargins(0,0,0,0) saveAsVerionLayout.setAlignment(QtCore.Qt.AlignLeft) saveAsVerionLayout.addWidget(saveAsVersionButton) saveAsVerionLayout.addWidget(self._saveAsVersionSpin) layout.addWidget(overwriteButton) layout.addWidget(saveAsmaxVersionButton) layout.addLayout(saveAsVerionLayout) # Standard buttons for Add/Cancel buttonbox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) layout.addWidget(buttonbox) self.setLayout(layout) ``` -------------------------------- ### Initialize Paint Points Function Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/math.html Defines the initial setup for the paintPoints function, including getting the geometry node from the active viewer and the selected camera. ```python def paintPoints(): geoNode = nuke.activeViewer().node() camera = nuke.selectedNode() ``` -------------------------------- ### Example RV Flipbook Implementation Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_modules/nukescripts/pyQtExamples/flipbookingExample.html This class extends `FlipbookApplication` to integrate Nuke's flipbooking with RV. It requires manual configuration of the RV executable path and handles sequence playback with optional region of interest and LUT settings. The `capabilities` method lists supported file types. ```python # Copyright (c) 2010 The Foundry Visionmongers Ltd. All Rights Reserved. import platform import sys import os.path import re import _thread import nuke import subprocess import nukescripts import nukescripts.flipbooking as flipbooking ################################################################################ # README # # This is an example script that demonstrated how to subimplement for RV. # You need to modify this to get it to work! # # To include this in nuke please add this to somewhere in the python search path # and add the following line to __init__.py (or menu.py): # from rv import * ################################################################################ [docs] class ExampleRVFlipbook(flipbooking.FlipbookApplication): """This is an example implementation of how to deal with implementing a flipbook application other than FrameCycler for Nuke. This script needs to be modified in several places before it can work, so please read all of the notes marked with TODO and modify them where necessary.""" def __init__(self): # TODO: Please put your own path in here or add RV path discovery. self._rvPath = "/Applications/RV64.app/Contents/MacOS/RV64" [docs] def name(self): return "RV" [docs] def path(self): return self._rvPath [docs] def cacheDir(self): return os.environ["NUKE_TEMP_DIR"] [docs] def run(self, filename, frameRanges, views, options): # TODO: You probably want more involved handling of frame ranges! sequence_interval = str(frameRanges.minFrame())+"-"+str(frameRanges.maxFrame()) os.path.normpath(filename) args = [] if nuke.env['WIN32']: args.append( "\"" + self.path() + "\"" ) filename = filename.replace("/", "\\") filename = "\"" + filename + "\"" else: args.append( self.path() ) roi = options.get("roi", None) if roi != None and not (roi["x"] == 0.0 and roi["y"] == 0.0 and roi["w"] == 0.0 and roi["h"] == 0.0): args.append("-c "+str(int(roi["x"]))) args.append(str(int(roi["y"]))) args.append(str(int(roi["w"]))) args.append(str(int(roi["h"]))) lut = options.get("lut", "") if lut == "linear-sRGB": args.append("-sRGB") elif lut == "linear-rec709": args.append('-rec709') args.append(filename) if sequence_interval: args.append(sequence_interval) #print args os.spawnv(os.P_NOWAITO, self.path(), args) [docs] def capabilities(self): return { 'proxyScale': False, 'crop': True, 'canPreLaunch': False, 'supportsArbitraryChannels': True, 'maximumViews' : 2, # TODO: This list is compiled from running rv with the following: # RV64 -formats | grep 'format "' | awk '{print $2}' | tr '[:space:]' ','; echo # This may differ for your platform! 'fileTypes' : ["j2k","jpt","jp2","dpx","cin","cineon","jpeg","jpg","rla","rpf","yuv","exr","openexr","sxr","tif","tiff","sm","tex","tx","tdl","shd","targa","tga","tpic","rgbe","hdr","iff","png","z","zfile","sgi","bw","rgb","rgba","*mraysubfile*","movieproc","stdinfb","aiff","aif","aifc","wav","snd","au","mov","avi","mp4","m4v","dv"] } flipbooking.register(ExampleRVFlipbook()) ``` -------------------------------- ### Shape and CV Panel Integration Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/rotopaint.html Integrates a Python panel to get user input for shape name, CV index, and frame range, then starts a tracking thread. ```python import examples node = nuke.selectedNode() p = examples.ShapeAndCVPanel(node) if p.showModalDialog(): fRange = nuke.FrameRange(p.fRange.value()) shapeName = p.shape.value() cv = p.cv.value() threading.Thread(None, _cvTracker, args=(node, shapeName, cv, fRange)).start() ``` -------------------------------- ### Get Node Input Modification Time Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/basics.html Retrieves the input modification time metadata for a specific frame and view. This is an example of accessing specific metadata keys like 'input/mtime'. ```python nuke.toNode("Read1").metadata("input/mtime", 93, "left") ``` -------------------------------- ### setupViewport Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.blinkscripteditor.ScriptInputArea.html Sets up the viewport widget. ```APIDOC ## setupViewport ### Description Initializes or configures the viewport widget. ### Method N/A (Method of a Python class) ### Parameters * **viewport** (PySide2.QtWidgets.QWidget) - The QWidget to set up as the viewport. ``` -------------------------------- ### Get File Sequence Notation Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/asset.html This function generates sequence notation for image files within a directory. It's a simplified example and may need adjustments for real-world use. ```python def getFileSeq( dirPath ): '''Return file sequence with same name as the parent directory. Very loose example!!''' dirName = os.path.basename( dirPath ) # COLLECT ALL FILES IN THE DIRECTORY THAT HVE THE SAME NAME AS THE DIRECTORY files = glob( os.path.join( dirPath, '%s.*.*' % dirName ) ) # GRAB THE RIGHT MOST DIGIT IN THE FIRST FRAME'S FILE NAME firstString = re.findall( r'\d+', files[0] )[-1] # GET THE PADDING FROM THE AMOUNT OF DIGITS padding = len( firstString ) # CREATE PADDING STRING FRO SEQUENCE NOTATION paddingString = '%02s' % padding # CONVERT TO INTEGER first = int( firstString ) # GET LAST FRAME last = int( re.findall( r'\d+', files[-1] )[-1] ) # GET EXTENSION ext = os.path.splitext( files[0] )[-1] # BUILD SEQUENCE NOTATION fileName = '%s.%%%sd%s %s-%s' % ( dirName, str(padding).zfill(2), ext, first, last ) # RETURN FULL PATH AS SEQUENCE NOTATION return os.path.join( dirPath, fileName ) ``` -------------------------------- ### Create and Connect Node for Scripting Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/basics.html This example shows how to create a node for scripting and immediately connect it as an input to the currently selected node using the setInput() function. ```python nuke.nodes.Blur().setInput(0, nuke.selectedNode()) ``` -------------------------------- ### Getting the Fully Qualified Name of a Knob Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.splinewarp.CurveKnob.html Returns the complete, unambiguous name of the knob within its node's hierarchy. This is useful for ensuring you are referencing the correct knob, especially in complex setups. ```python >>> knob.fullyQualifiedName() ``` -------------------------------- ### Get Dependent Nodes in Nuke Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.dependentNodes.html This example demonstrates how to find dependent nodes in Nuke. It specifies that we are interested in nodes connected via inputs, hidden inputs, and expressions, and targets a specific Blur node. ```python n1 = nuke.nodes.Blur() n2 = nuke.nodes.Merge() n2.setInput(0, n1) ndeps = nuke.dependentNodes(nuke.INPUTS | nuke.HIDDEN_INPUTS | nuke.EXPRESSIONS, [n1]) ``` -------------------------------- ### QApplication Methods Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.cache.QApplication.html This section details the various methods available for the QApplication class, including static methods for application-wide operations and instance methods for specific application objects. ```APIDOC ## QApplication Methods This document outlines the methods available for the `QApplication` class within the `nukescripts.cache` module. These methods allow for the management of application events, settings, and interactions with the graphical environment. ### Static Methods - **_fontMetrics()** - Returns the `QFontMetrics` for the application. - **_globalStrut()** - Returns the global strut `QSize`. - **_hasPendingEvents()** - Checks if there are pending events in the application's event queue. - **_highDpiScaleFactorRoundingPolicy()** - Returns the high DPI scale factor rounding policy. - **_inputMethod()** - Returns the `QInputMethod` for the application. - **_installTranslator(messageFile: PySide2.QtCore.QTranslator)** - Installs a translator for the application. - **_instance()** - Returns the singleton instance of `QCoreApplication`. - **_isEffectEnabled(arg__1: PySide2.QtCore.Qt.UIEffect)** - Checks if a specific UI effect is enabled. - **_isFallbackSessionManagementEnabled()** - Checks if fallback session management is enabled. - **_isLeftToRight()** - Checks if the application's layout is left-to-right. - **_isQuitLockEnabled()** - Checks if the quit lock is enabled. - **_isRightToLeft()** - Checks if the application's layout is right-to-left. - **_isSetuidAllowed()** - Checks if setuid is allowed. - **_keyboardInputInterval()** - Returns the keyboard input interval. - **_keyboardModifiers()** - Returns the current keyboard modifiers. - **_layoutDirection()** - Returns the application's layout direction. - **_libraryPaths()** - Returns a list of the application's library paths. - **_modalWindow()** - Returns the current modal window. - **_mouseButtons()** - Returns the current mouse buttons. - **_organizationDomain()** - Returns the organization domain name. - **_organizationName()** - Returns the organization name. - **_overrideCursor()** - Returns the overridden cursor. - **_palette(arg__1: PySide2.QtWidgets.QWidget)** - Returns the palette for a given widget. - **_palette(className: bytes)** - Returns the palette for a given class name. - **_palette()** - Returns the application's default palette. - **_platformName()** - Returns the name of the platform. - **_postEvent(receiver: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent, priority: PySide2.QtCore.Qt.EventPriority = PySide2.QtCore.Qt.EventPriority.NormalEventPriority)** - Posts an event to a receiver. - **_primaryScreen()** - Returns the primary screen. - **_processEvents(flags: PySide2.QtCore.QEventLoop.ProcessEventsFlags, maxtime: int)** - Processes events with specified flags and maximum time. - **_processEvents(flags: PySide2.QtCore.QEventLoop.ProcessEventsFlags = PySide2.QtCore.QEventLoop.ProcessEventsFlag.AllEvents_)** - Processes events with specified flags. - **_queryKeyboardModifiers()** - Queries the current keyboard modifiers. - **_quit()** - Quits the application. - **_quitOnLastWindowClosed()** - Checks if the application quits when the last window is closed. - **_registerUserData()** - Registers user data. - **_removeLibraryPath(arg__1: str)** - Removes a library path. - **_removePostedEvents(receiver: PySide2.QtCore.QObject, event_type: int = 0)** - Removes posted events for a receiver. - **_removeTranslator(messageFile: PySide2.QtCore.QTranslator)** - Removes a translator from the application. - **_restoreOverrideCursor()** - Restores the default cursor. - **_screens()** - Returns a list of all available screens. - **_screenAt(point: PySide2.QtCore.QPoint)** - Returns the screen at a given point. - **_sendEvent(receiver: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent)** - Sends an event to a receiver. - **_sendPostedEvents(receiver: Optional[PySide2.QtCore.QObject] = None, event_type: int = 0)** - Sends posted events. - **_setActiveWindow(act: PySide2.QtWidgets.QWidget)** - Sets the active window. - **_setApplicationDisplayName(name: str)** - Sets the application display name. - **_setApplicationName(application: str)** - Sets the application name. - **_setApplicationVersion(version: str)** - Sets the application version. - **_setAttribute(attribute: PySide2.QtCore.Qt.ApplicationAttribute, on: bool = True)** - Sets an application attribute. - **_setColorSpec(arg__1: int)** - Sets the color specification. - **_setCursorFlashTime(arg__1: int)** - Sets the cursor flash time. - **_setDesktopFileName(name: str)** - Sets the desktop file name. - **_setDesktopSettingsAware(on: bool)** - Sets whether desktop settings are aware. - **_setDoubleClickInterval(arg__1: int)** - Sets the double-click interval. - **_setEffectEnabled(arg__1: PySide2.QtCore.Qt.UIEffect, enable: bool = True)** - Enables or disables a UI effect. ### Instance Methods - **inherits(_self_, _classname: bytes)** - Checks if the object inherits from a given class name. - **isSavingSession(_self_)** - Checks if the session is currently being saved. - **isSessionRestored(_self_)** - Checks if the session has been restored. - **isSignalConnected(_self_, _signal: PySide2.QtCore.QMetaMethod)** - Checks if a signal is connected. - **isWidgetType(_self_)** - Checks if the object is a widget type. - **isWindowType(_self_)** - Checks if the object is a window type. - **killTimer(_self_, _id: int)** - Kills a timer with the given ID. - **metaObject(_self_)** - Returns the meta-object of the instance. - **moveToThread(_self_, _thread: PySide2.QtCore.QThread)** - Moves the object to a different thread. - **notify(_self_, _arg__1: PySide2.QtCore.QObject, _arg__2: PySide2.QtCore.QEvent)** - Handles event notification. - **objectName(_self_)** - Returns the object's name. - **parent(_self_)** - Returns the parent object. - **property(_self_, _name: bytes)** - Returns the value of a property. - **receivers(_self_, _signal: bytes)** - Returns the number of receivers for a signal. - **removeEventFilter(_self_, _obj: PySide2.QtCore.QObject)** - Removes an event filter. - **removeNativeEventFilter(_self_, _filterObj: PySide2.QtCore.QAbstractNativeEventFilter)** - Removes a native event filter. - **sender(_self_)** - Returns the sender of a signal. - **senderSignalIndex(_self_)** - Returns the index of the sender's signal. - **sessionId(_self_)** - Returns the session ID. - **sessionKey(_self_)** - Returns the session key. - **setAutoSipEnabled(_self_, _enabled: bool)** - Enables or disables auto SIP. ``` -------------------------------- ### Evaluating a Shape's curve at a specific time Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.rotopaint.Shape.html Bakes out a curve for the outline of a shape at a specified time. This example shows how to get both the main curve and the feather curve, and how to calculate a point on the feather curve by adding the feather offset to the main curve point. ```python frameNum = 10.0 t = 0.5 rotoknob = nuke.toNode('RotoPaint1')['curves'] shape = rotoknob.toElement('Bezier1') mainCurve = shape.evaluate(0, frameNum) featherCurve = shape.evaluate(1, frameNum) pointOnMainCurve = mainCurve.getPoint(t) featherOffset = featherCurve.getPoint(t) pointOnFeatherCurve = pointOnMainCurve + featherOffset ``` -------------------------------- ### Complete Script Setup Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/rotopaint.html Combines node selection, parameter definition, and threaded execution for the CV tracking script. ```python import nuke.rotopaint as rp node = nuke.selectedNode() fRange = nuke.FrameRange('1-100') shapeName = 'Bezier1' cv = 0 threading.Thread(None, _cvTracker, args=(node, shapeName, cv, fRange)).start() ``` -------------------------------- ### Initialize Windows Hardware Info Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_modules/nukescripts/hardwareinfo.html Sets the OS to 'win' and populates hardware details by querying the Windows Registry and using helper functions. ```python def initWin(self): import ctypes self._standardDict[gOS] = "win" self._standardDict[gCPUType] = self.getRegistryValue("HKEY_LOCAL_MACHINE", "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString") self._standardDict[gCPUSpeed] = self.getRegistryValue("HKEY_LOCAL_MACHINE", "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz") self._standardDict[gNumCores] = self.getRegistryNumSubKeys("HKEY_LOCAL_MACHINE", "HARDWARE\DESCRIPTION\System\CentralProcessor") self._standardDict[gRAM] = self.SafeCall(self.getWindowsRam) self._standardDict[gRAM] = ConvertMemSizeToKb(self._standardDict[gRAM]) self._standardDict[gOSVersion] = self.SafeCall(self.getWindowsOSVersion) self._standardDict[gL2Cache] = self.SafeCall(self.getWindowsL2Cache) self._standardDict[gMachineName] = self.SafeCall(self.getWindowsMachineName) ``` -------------------------------- ### Get Translation Key Time Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.curvelib.AnimCTransform.html Gets the time for a specific key on the translation attribute. The view parameter is optional. ```APIDOC ## getTranslationKeyTime ### Description Get the time for a specific key on the translation attribute. ### Method getTranslationKeyTime(_index_, _view_) ### Parameters - **_index_** (int) - The index of the key. - **_view_** (any) - Optional view parameter. ### Returns float - The time of the specified key. ``` -------------------------------- ### run Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nukescripts.pyQtExamples.flipbookingExample.ExampleRVFlipbook.html Executes the flipbook on a specified path with given frame ranges, views, and options. ```APIDOC ## run ### Description Execute the flipbook on a path. ### Method `run(_filename_ , _frameRanges_ , _views_ , _options_)` ### Parameters - **filename**: The path to run the flipbook on. This will be similar to /path/to/foo%03d.exr. - **frameRanges**: A FrameRanges object representing the range that should be flipbooked. Note that in 6.2v1-2 this was a FrameRange object. - **views**: A list of strings comprising of the views to flipbook. Will not be more than the maximum supported by the flipbook. - **options**: A dictionary of options to use. This may contain the keys pixelAspect, roi, dimensions, audio and lut. These contain a float, a dict with bounding box dimensions, a dict with width and height, a path to audio file and a string indicating the LUT conversion to apply. ### Returns - None ``` -------------------------------- ### Get SkewX Key Time Source: https://learn.foundry.com/nuke/developers/15.0/pythondevguide/_autosummary/nuke.curvelib.AnimCTransform.html Gets the time for a specific key on the skewX attribute. The view parameter is optional. ```APIDOC ## getSkewXKeyTime ### Description Get the time for a specific key on the skewX attribute. ### Method getSkewXKeyTime(_index_, _view_) ### Parameters - **_index_** (int) - The index of the key. - **_view_** (any) - Optional view parameter. ### Returns float - The time of the specified key. ```