Example #1
0
    def __init__ (self) :
        self.rvc = rvNetwork.RvCommunicator("Nuke");
        self.port = 45128
        self.initialized = False
        self.running = False
        self.selectedNode = None

        self.commands = self.LockedFifo()
	self.crashFlag = self.LockedFlag()

        self.sessionDir = ""
        self.syncSelection = False
        self.syncFrameChange = False
        self.syncReadChanges = False
        self.rvExecPath = ""

        self.updateFromPrefs()

        self.portFile = self.sessionDir + "/rv" + str(os.getpid())

        self.zoomTargetNode = None

        log ("adding callbacks")
        # nuke.addUpdateUI (self.updateUI)
        nuke.addKnobChanged (self.knobChanged)
        nuke.addOnCreate (self.onCreate)
        nuke.addOnDestroy (self.onDestroy)
        nuke.addOnScriptClose (self.onScriptClose)
        nuke.addOnScriptLoad (self.onScriptLoad)
Example #2
0
    def __init__(self):
        self.rvc = rvNetwork.RvCommunicator("Nuke")
        self.port = 45128
        self.initialized = False
        self.running = False
        self.selectedNode = None

        self.commands = self.LockedFifo()
        self.crashFlag = self.LockedFlag()

        self.sessionDir = ""
        self.syncSelection = False
        self.syncFrameChange = False
        self.syncReadChanges = False
        self.rvExecPath = ""

        self.updateFromPrefs()

        self.portFile = self.sessionDir + "/rv" + str(os.getpid())

        self.zoomTargetNode = None

        log("adding callbacks")
        # nuke.addUpdateUI (self.updateUI)
        nuke.addKnobChanged(self.knobChanged)
        nuke.addOnCreate(self.onCreate)
        nuke.addOnDestroy(self.onDestroy)
        nuke.addOnScriptClose(self.onScriptClose)
        nuke.addOnScriptLoad(self.onScriptLoad)
Example #3
0
    def restoreComplete(self):
        log("restoreComplete")

        nuke.addKnobChanged(self.knobChanged)
        nuke.addOnCreate(self.onCreate)
        nuke.addOnDestroy(self.onDestroy)

        self.allSyncUpdate()
Example #4
0
 def addCallbackOnDestroy(self, func, nodeClass=None, group=None):
     self._addNukeCallbackGroup(group)
     self.windowInstance()['callback'][group]['onDestroy'][func].add(nodeClass)
     if not self.__windowHidden:
         if nodeClass is None:
             nuke.addOnDestroy(func)
         else:
             nuke.addOnDestroy(func, nodeClass=nodeClass)
Example #5
0
 def addNukeCallback(self):
     '''add method to Nuke callback list'''
     if '*' not in nuke.onCreates or (self.nukeCreateNodeCallback, (), {}, None) not in nuke.onCreates['*']:
         nuke.addOnCreate(self.nukeCreateNodeCallback)
     if '*' not in nuke.onDestroys or (self.nukeDestroyNodeCallback, (), {}, None) not in nuke.onDestroys['*']:
         nuke.addOnDestroy(self.nukeDestroyNodeCallback)
     if '*' not in nuke.knobChangeds or (self.nukeSelectionCallback, (), {}, None) not in nuke.knobChangeds['*']:
         nuke.addKnobChanged(self.nukeSelectionCallback)
Example #6
0
    def restoreComplete (self) :
        log ("restoreComplete")

        nuke.addKnobChanged (self.knobChanged)
        nuke.addOnCreate (self.onCreate)
        nuke.addOnDestroy (self.onDestroy)

        self.allSyncUpdate()
		def __init__(self):
			# Set up the user interface from Designer.
						
			self.ui = uic.loadUi( self.uipath() )
			self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"), self.render)
			self.ui.connect(self.ui.refreshButton, QtCore.SIGNAL("clicked()"), self.refresh)
			nuke.addOnCreate(self.onCreateCallback)
			nuke.addOnDestroy(pyQtThreadCleanupCallback, nodeClass='Root')

			self.setdefaults()

			self.ui.show()
Example #8
0
        def __init__(self):
            # Set up the user interface from Designer.

            self.ui = uic.loadUi(self.uipath())
            self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"),
                            self.render)
            self.ui.connect(self.ui.refreshButton, QtCore.SIGNAL("clicked()"),
                            self.refresh)
            nuke.addOnCreate(self.onCreateCallback)
            nuke.addOnDestroy(pyQtThreadCleanupCallback, nodeClass='Root')

            self.setdefaults()

            self.ui.show()
Example #9
0
    def setInitialValues(self):

        self.nodeSelection.addItems(['All', 'Selected'])
        self.search.setPlaceholderText('Search')
        self.replace.setPlaceholderText('Replace')
        self.infoBox.setReadOnly(True)
        self.infoBox.setFont(QtGui.QFont('Consolas', 10))

        self.search.textChanged.connect(self.populateInfo)
        self.replace.textChanged.connect(self.populateInfo)
        self.classLimit.currentIndexChanged.connect(self.populateInfo)

        nuke.addOnCreate(
            lambda: QtCore.QTimer.singleShot(0, self.updateClasses))
        nuke.addOnDestroy(
            lambda: QtCore.QTimer.singleShot(0, self.updateClasses))
Example #10
0
def moblur_controller():

    # Check if the Nuke script already has a GLOBAL_MOTIONBLUR_CONTROLLER NoOp node.
    for x in nuke.allNodes('NoOp'):
        if x.name() == "GLOBAL_MOTIONBLUR_CONTROLLER":
            nuke.message("You already have one of those in your script!")
            return

    # Create a list to hold nodes.
    node_list = []

    # Loop through all nodes, and the ones that have a motionblur or samples knob, add them to node_list.
    for n in nuke.allNodes():
        if n.knob('motionblur') or n.knob('samples'):
            node_list.append(n)

    # Create a NoOp node, and set it's name.
    NoOp = nuke.createNode('NoOp')
    NoOp['name'].setValue("GLOBAL_MOTIONBLUR_CONTROLLER")

    # Make the node black, and the text bold.
    NoOp['tile_color'].setValue(255)
    NoOp['note_font'].setValue("Bold")

    # Add knobs to the NoOp node. One for motionblur samples, one for the shutter, and a third to disable all motionblur.
    NoOp.addKnob(nuke.Int_Knob('global_motionblur', "motionblur"))
    NoOp.addKnob(nuke.Double_Knob('global_shutter', "shutter"))
    NoOp.addKnob(
        nuke.Boolean_Knob('global_disable_moblur', "disable motionblur"))
    NoOp['global_disable_moblur'].setFlag(nuke.STARTLINE)

    # Set default values of out knobs
    NoOp['global_motionblur'].setValue(1)
    NoOp['global_shutter'].setValue(0.5)

    # Loop through all the nodes in node_list.
    for node in node_list:
        # If the node has a motionblur knob
        if node.knob('motionblur'):
            # Set an expression that links said motionblur knob to our global moblur NoOp's motionblur knob value.
            # There is a TCL if/else statement here saying, "If the disable_moblur knob is not checked,
            #      set the value to the GLOBAL_MOTIONBLUR_CONTROLLER's global_motionblur knob.
            #      Otherwise, set the value to 0."
            node['motionblur'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 0'
            )
            # Same thing here -- setting an expression to link the value to the new global_shutter knob on our NoOp node.
            node['shutter'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter')

        # If the node doesn't have a motionblur knob, but it does have a samples knob, we still want to add the same expression.
        # The only difference here is that the samples knob is always 1 by default, so we should match that with our code.
        elif node.knob('samples'):
            node['samples'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 1'
            )
            node['shutter'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter')

    # Define function to use in addOnCreate(), for when new nodes with motionblur knobs are created AFTER our NoOp node is created.
    # We're adding the expressions to the knobs exactly the same way we are when we create the NoOp node to begin with.
    def addExpr():

        tn = nuke.thisNode()

        if tn.knob('motionblur'):
            tn['motionblur'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 0'
            )
            tn['shutter'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter')

        elif tn.knob('samples'):
            tn['samples'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_disable_moblur == 0 ? GLOBAL_MOTIONBLUR_CONTROLLER.global_motionblur : 1'
            )
            tn['shutter'].setExpression(
                'GLOBAL_MOTIONBLUR_CONTROLLER.global_shutter')

    # Any time a new node is created, the addExpr() function will run.
    # If a node without motionblur, samples and/or shutter knobs is created, this addOnCreate() will be ignored.
    nuke.addOnCreate(addExpr)

    # Define another function to use in nuke.addOnDestroy(), so when the NoOp node gets deleted,
    # all expression-links are removed and node values are set back to their defaults.
    def deleteExpressions():

        for node in nuke.allNodes():
            if node.knob('motionblur'):
                node['motionblur'].clearAnimated()
                node['motionblur'].setValue(0)
                node['shutter'].clearAnimated()
                node['shutter'].setValue(0.5)

            elif node.knob('samples'):
                node['samples'].clearAnimated()
                node['samples'].setValue(1)
                node['shutter'].clearAnimated()
                node['shutter'].setValue(0.5)

            nuke.removeOnCreate(addExpr)

    # Like addOnCreate, except it runs when the node is deleted.
    # The argument it takes is a the name of a function to run...
    nuke.addOnDestroy(deleteExpressions, nodeClass="NoOp")
Example #11
0
def _cbk(name):
    nuke.tprint(name + " " + nuke.thisNode().name() + "." +
                nuke.thisKnob().name())


nuke.addOnUserCreate(_cb, ("onUserCreate"))

nuke.addOnCreate(_cb, ("onCreate"))

nuke.addOnScriptLoad(_cb, ("onScriptLoad"))

nuke.addOnScriptSave(_cb, ("onScriptSave"))

nuke.addOnScriptClose(_cb, ("onScriptClose"))

nuke.addOnDestroy(_cb, ("onDestroy"))

nuke.addKnobChanged(_cbk, ("knobChanged"))

nuke.addUpdateUI(_cb, ("updateUI"))

nuke.addAutolabel(_cb, ("autolabel"))

nuke.addBeforeRender(_cb, ("beforeRender"))

nuke.addBeforeFrameRender(_cb, ("beforeFrameRender"))

nuke.addAfterFrameRender(_cb, ("afterFrameRender"))

nuke.addAfterRender(_cb, ("afterRender"))
Example #12
0
    def coreFunction(self):
        coreLayout = QtWidgets.QVBoxLayout()
        tertiary_layout = QtWidgets.QHBoxLayout()

        label_cwd = QtWidgets.QLabel()
        label_cwd.setText("Current Working Directory =")
        tertiary_layout.addWidget(label_cwd)

        field_cwd = QtWidgets.QLineEdit(label_cwd)
        field_cwd.setText(self.SCRIPT_DIR)
        field_cwd.setFont(self.italicFont)
        field_cwd.setStyleSheet('color: rgb(128, 128, 128)')
        field_cwd.setReadOnly(1)
        tertiary_layout.addWidget(field_cwd)

        coreLayout.addLayout(tertiary_layout)

        #--- BEGIN TABS ---#
        #initializes the 'tabBar' 'QtWidgets.QTabWidget()' object, and adds both 'tab_readNodes' and 'tab_writeNodes' to it as 'QtWidgets.QWidget()' objects
        tabBar = QtWidgets.QTabWidget()
        self.tab_readNodes = QtWidgets.QWidget()
        self.tab_writeNodes = QtWidgets.QWidget()
        tabBar.addTab(self.tab_readNodes, 'Read Nodes')
        tabBar.addTab(self.tab_writeNodes, 'Write Nodes')
        #creates 2 instances of 'QtWidgets.QVBoxLayout' within both the 'tab_readNodes' and 'tab_writeNodes' objects based on the current working Nuke script
        self.tab_readNodes.layout = QtWidgets.QVBoxLayout()
        self.tab_writeNodes.layout = QtWidgets.QVBoxLayout()

        #--- BEGIN READ NODES TABLE ---#
        #initializes the 'table_readNodes' 'QtWidgets.QTableWidget()' object with default parameters
        self.table_readNodes = QtWidgets.QTableWidget()
        self.table_readNodes.setColumnCount(3)
        self.table_readNodes.setHorizontalHeaderLabels(
            ['Absolute Pathnames', 'Relative Pathnames', 'Disable/Enable'])
        self.table_readNodes.setWordWrap(0)
        self.table_readNodes.setRowCount(0)
        #calls the 'generateReadsData()' private method that will populate the 'table_readNodes' object based on the current Nuke working script
        self.generateTable_reads()
        #try:
        #    #removes the custom 'nuke.onCreate()' callback that was created within th the 'pathConverter_window' class.  This prevents duplicate callbacks from being created.
        #    nuke.removeOnUserCreate(self.generateTable_reads)
        #    print "TRY statement was succesful."
        #except:
        #    print "TRY statement has encountered an error.  Now printing the EXCEPTION."
        #    nuke.addOnUserCreate(self.generateTable_reads)
        #if self.generateTable_reads in nuke.onUserCreates.values():
        #    nuke.removeOnUserCreate(self.generateTable_reads)
        #nuke.addOnUserCreate(self.generateTable_reads)
        nuke.removeOnUserCreate(self.myFunction, nodeClass='Read')
        nuke.removeOnDestroy(self.myFunction, nodeClass='Read')
        nuke.addOnUserCreate(self.myFunction, nodeClass='Read')
        nuke.addOnDestroy(self.myFunction, nodeClass='Read')
        #if self.myFunction in nuke.onUserCreates['Read']:
        #    print str(self.myFunction) + ' exists within the nuke.addOnUserCreates dictionary.'
        #    nuke.removeOnUserCreate(self.myFunction)

        #-----------------------
        self.tab_readNodes.layout.addWidget(self.table_readNodes)
        self.tab_readNodes.setLayout(self.tab_readNodes.layout)
        #-----------------------

        #within the 'self.table_readNodes' object, whenever a selection change occurs, invoke the 'self.__changeSelection_reads' function
        self.table_readNodes.itemSelectionChanged.connect(
            self.__changeSelection_reads)
        #--- END READ NODES TABLE ---#

        #--- WRITE NODES TABLE ---#
        #initializes the 'table_writeNodes' 'QtWidgets.QTableWidget()' object with default parameters
        self.table_writeNodes = QtWidgets.QTableWidget()
        self.table_writeNodes.setColumnCount(3)
        self.table_writeNodes.setHorizontalHeaderLabels(
            ['Absolute Pathnames', 'Relative Pathnames', 'Disable/Enable'])
        self.table_writeNodes.setWordWrap(0)
        self.table_writeNodes.setRowCount(0)
        #calls the '__generateWritesData()' private method that will populate the 'table_writeNodes' object based on the current working Nuke script
        self.generateTable_writes()
        #within the 'self.table_writeNodes' object, whenever a selection change occurs, invoke the 'self.__changeSelection_writes' function
        self.table_writeNodes.itemSelectionChanged.connect(
            self.__changeSelection_writes)

        #--------------------------
        self.tab_writeNodes.layout.addWidget(self.table_writeNodes)
        self.tab_writeNodes.setLayout(self.tab_writeNodes.layout)
        #--------------------------
        #--- END WRITE NODES TABLE ---#

        #adds the 'tabBar' object to the 'coreLayout' 'QtWidgets.Layout()' object
        coreLayout.addWidget(tabBar)
        #--- END TABS ---#

        txt_os = QtWidgets.QLabel()
        txt_os.setText(platform.platform())
        txt_os.setAlignment(QtCore.Qt.AlignRight)
        coreLayout.addWidget(txt_os)

        self.primary_layout.addLayout(coreLayout)
 def addNukeCallBacks(self):
     try:
         nuke.addOnUserCreate(self.refreshListOfNodes)
         nuke.addOnDestroy(self.refreshListOfNodes)
     except:
         pass
 def __initCallbacks(self):
     nuke.addOnCreate(self.updateNodeTree)                               # If a new node is created, the nodeType tableView will be updated
     nuke.addOnDestroy(self.updateNodeTree)                              # TODO: Doesn't seem to update, looks like we need to find a way to call the update AFTER the node is destroyed