def setup_cryptomatte():
    nuke.addKnobChanged(lambda: cryptomatte_knob_changed_event(
        nuke.thisNode(), nuke.thisKnob()), nodeClass='Cryptomatte')
    nuke.addKnobChanged(lambda: encryptomatte_knob_changed_event(
        nuke.thisNode(), nuke.thisKnob()), nodeClass='Encryptomatte')
    nuke.addOnCreate(lambda: encryptomatte_on_create_event(
        nuke.thisNode(), nuke.thisKnob()), nodeClass='Encryptomatte')
Esempio n. 2
0
def nk_virtual_axis():
	"""
	Virtual Axis
	"""
	control = nuke.nodes.Axis()
	deltas = {}

	def add(a,b):
		return [v+b[i] for (i,v) in enumerate(a)] if type(a)==list else a+b
			
	def diff(new,old):
		return [v-old[i] for (i,v) in enumerate(new)] if type(new)==list else new-old

	def callback():
		k = nuke.thisKnob()
		name, v = k.name(), k.value()
		if not deltas.has_key(name):
			deltas[name] = v
			d = deltas[name]
		else:
			d = diff(v,deltas[name])
			deltas[name] = v
		[n[name].setValue(add(n[name].value(),d)) for n in nuke._allNodes() if n['selected'].value() and n!=control and n.knobs().has_key(name)]

	nuke.addKnobChanged(callback, args=(), kwargs={}, node=control)
Esempio n. 3
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)
Esempio n. 4
0
    def restoreComplete (self) :
        log ("restoreComplete")

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

        self.allSyncUpdate()
def setup_cryptomatte():
    nuke.addKnobChanged(lambda: cryptomatte_knob_changed_event(
        nuke.thisNode(), nuke.thisKnob()), nodeClass='Cryptomatte')

    if nuke.GUI:
        toolbar = nuke.menu("Nodes")
        automatte_menu = toolbar.addMenu("Cryptomatte", "cryptomatte_logo.png")
        automatte_menu.addCommand("Cryptomatte", "import cryptomatte_utilities as cu; cu.cryptomatte_create_gizmo();")
        automatte_menu.addCommand("Decryptomatte All", "import cryptomatte_utilities as cu; cu.decryptomatte_all();")
        automatte_menu.addCommand("Decryptomatte Selection", "import cryptomatte_utilities as cu; cu.decryptomatte_selected();")
Esempio n. 6
0
def enablemenus():
    turnon = ["JEEVES/Save","JEEVES/Write", "JEEVES/Read"]
    for each in turnon:
        m = nuke.menu( 'Nuke' ).findItem(each)
        m.setEnabled( True )
    
    m = nuke.menu( 'Nuke' ).findItem("JEEVES/Connect to Jeeves")
    #m.setEnabled( False )
    
    nuke.addAutoSaveFilter( nukePipe.nukeCallbacks.onAutoSave )
    nuke.addAutoSaveRestoreFilter( nukePipe.nukeCallbacks.onAutoSaveRestore )
    nuke.addAutoSaveDeleteFilter( nukePipe.nukeCallbacks.onAutoSaveDelete )
    nuke.addKnobChanged(nukePipe.nukeCallbacks.findChangedKnob, nodeClass='Write')
    
    nuke.addFavoriteDir('job_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB')))
    nuke.addFavoriteDir('script_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', 'nuke', os.getenv('SHOT'), 'scripts', jeeves_core.user))
    nuke.addFavoriteDir('plates_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', 'nuke', os.getenv('SHOT'), 'plates'))
    nuke.addFavoriteDir('assets', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', 'assets'))
    nuke.addFavoriteDir('3d_renders', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'vfx', '3d', os.getenv('SHOT'), 'Render_Pictures'))
    nuke.addFavoriteDir('grade_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'grade'))
    nuke.addFavoriteDir('media_dir', os.path.join(jeeves_core.jobsRoot, os.getenv('JOB'), 'media_imports'))
Esempio n. 7
0
def nk_backburner():
	"""
	Background render
	Note: this assumes that the nuke executable is in PATH
	"""
	nuke.scriptSave()
	op = nuke.root()['name'].value()
	name = nuke.selectedNode().name()
	np = op+"_%s.bburn"%name
	shutil.copy2(op,np)
	ranges = "%s-%s" % (nuke.root().firstFrame(),nuke.root().lastFrame())
	cmd = """ "%s" -m %i -F %s -X %s -ix %s""" % (nuke.EXE_PATH, int(nuke.env['numCPUs']/2), ranges, name, np)
	print cmd

	def render():
		print "Background rendering %s" % name
		try:
			Popen(cmd).wait()
		except WindowsError: # TODO: WTF is up with this?
			os.popen(cmd).read()
		nuke.message("%s Background render finished!" % name)
		nuke.executeInMainThread(nuke.toNode(name)['reading'].setValue,True)
		os.remove(np)

	def changeNodeColor(thisName):
		if nuke.thisNode().name() == thisName:
			nuke.executeInMainThread(nuke.toNode(thisName)['tile_color'].setValue,552079871)
			nuke.executeInMainThread(nuke.toNode(thisName)['postage_stamp'].setValue,True)
			nuke.removeKnobChanged(changeNodeColor,thisName,{},"Write")

	this = nuke.toNode(name)
	this['tile_color'].setValue(943405567)
	this['postage_stamp'].setValue(False)
	this['reading'].setValue(False)

	nuke.addKnobChanged(changeNodeColor,name,{},"Write")

	T = threading.Thread(target=render)
	T.start()
Esempio n. 8
0
def toggleKiss():
	'''
	globally toggle enable/disable the kiss function
	save node data
	'''

	#save all nodenames, positions and dimensions
	for node in nuke.allNodes():
		nodeName.append(node.name())
		nodeX.append(node.xpos())
		nodeY.append(node.ypos())
		nodeWidth.append(node.screenWidth())
		nodeHeight.append(node.screenHeight())

	#toggle KISS
	if nuke.KISS==False:
		nuke.KISS=True
		nuke.addKnobChanged(kissNodes)
		print "enable kiss"
	else:
		nuke.KISS=False
		nuke.removeKnobChanged(kissNodes)
		print "disable kiss"
Esempio n. 9
0
import nuke
import revealInFinder

print "Passing through revealInFinder menu.py"

node_classes = [
    "Read", "Write", "Camera", "Camera2", "ReadGeo", "ReadGeo2", "WriteGeo"
]

for node in node_classes:
    nuke.addOnUserCreate(revealInFinder.add_reveal_button, nodeClass=node)
    nuke.addKnobChanged(revealInFinder.reveal_in_finder, nodeClass=node)
Esempio n. 10
0
        rNodes = nuke.selectedNodes()
        for n in rNodes:
            if n['LinkedStamp'].value():
                n.setInput(0, nuke.toNode(n['connect'].value()))


def inputUpdate():

    n = nuke.thisNode()
    k = nuke.thisKnob()
    if n.Class() in ['PostageStamp', 'NoOp']:
        if k.name() == "inputChange":
            if len(n.dependencies()) <= 0:
                n['note_font'].setValue('bold')
                n['note_font_color'].setValue(3623878911)  # Dark Red
                n['hide_input'].setValue(False)
                print '%s disconnected' % n.name()
            elif len(n.dependencies()) > 0:
                n['connect'].setValue(n.dependencies()[0].name())
                n['tx_nodename'].setValue(n['connect'].value())
                n['note_font'].setValue('')
                n['note_font_color'].setValue(0)
                n['hide_input'].setValue(True)
                print '%s connected' % n.name()
        elif k.name() == 'tx_nodename':
            n['connect'].setValue(k.value())


nuke.addKnobChanged(inputUpdate, nodeClass='PostageStamp')
nuke.addKnobChanged(inputUpdate, nodeClass='NoOp')
Esempio n. 11
0
def setLocal():

    # path variables

    repo = '/mnt/karramba'
    home = '/home/tfx/job.local'

    # clears the selection if smth was selected
    for node in nuke.allNodes():
        node.setSelected(False)

# copies footage to local machine

    readList = [node.knob('file').value() for node in nuke.allNodes('Read')]

    for path in readList:

        fileDirList = [
            path.rsplit(os.sep, 1)[0] + os.sep + img
            for img in os.listdir(path.rsplit(os.sep, 1)[0])
            if img[:len(path.rsplit(os.sep, 1)[1].split('%')[0])] ==
            path.rsplit(os.sep, 1)[1].split('%')[0]
        ]
        newPath = home + path.rsplit(os.sep, 1)[0].split(repo)[-1] + os.sep

        if not os.path.exists(newPath):
            os.makedirs(newPath)

        for img in fileDirList:
            if not os.path.isdir(img):
                shutil.copy(img, newPath)


#creates new read nodes and controller to switch controller between local and network

    for node in nuke.allNodes('Read'):

        node.setSelected(True)

        sw = nuke.createNode('Switch', inpanel=False)
        sw.setSelected(False)
        sw.knob('which').setExpression('locController.location')
        node.setSelected(True)
        nuke.nodeCopy('%context%')
        c = nuke.nodePaste('%context%')

        sw.setInput(0, c)
        sw.setInput(1, node)

        node.setYpos(node.ypos() - 90)
        c.setYpos(node.ypos())
        c.setXpos(node.xpos() - 150)

        c.setName(c.name() + 'Local')
        node.setName(node.name() + 'Network')

        c.knob('file').setValue(home +
                                node.knob('file').value().split(repo)[-1])

        node.setSelected(False)
        c.setSelected(False)

    n = nuke.createNode('NoOp')
    n.setName('locController')
    k = nuke.Double_Knob('location', 'location')
    k.setRange(0, 1)
    n.addKnob(k)
    n.knob('hide_input').setValue(True)
    n.setXpos(nuke.toNode(findHighestRead()).xpos() + 500)
    n.setYpos(nuke.toNode(findHighestRead()).ypos())
    n.setSelected(False)

    st = nuke.createNode('StickyNote', inpanel=False)
    st.setName('status')
    st.setXpos(n.xpos())
    st.setYpos(n.ypos() - 50)
    st.knob('label').setValue('LOCAL')
    st.knob('note_font_size').setValue(35)

    nuke.addKnobChanged(switchStatus, nodeClass='NoOp')
Esempio n. 12
0
 def callbackLockThisViewer9():
     nuke.addKnobChanged(LockThisViewer9,nodeClass='Viewer')
Esempio n. 13
0
import nuke

PANEL_HISTORY = []

def close_panel():
	if nuke.thisKnob().name()=='hidePanel':
		PANEL_HISTORY.append(nuke.thisNode().name())

nuke.addKnobChanged(close_panel)

def nk_reopen_panels():
	"""
	Reopen panels
	SS Alt+q
	"""
	if len(PANEL_HISTORY)>0:
		last_node = nuke.toNode(PANEL_HISTORY.pop())
		if last_node is not None:
			last_node.showControlPanel()
	else:
		nuke.message("No more panels to reopen!")
Esempio n. 14
0
			rfui.setVisible(True)
			rfui.setLabel("search word")
			crfp.setVisible(False)
		elif n["rootFolderMethod"].value() == "environment variables":
			rfui.setVisible(True)
			rfui.setLabel("env variables/path")
			crfp.setVisible(False)
		elif n["rootFolderMethod"].value() == "custom path":
			rfui.setVisible(False)
			crfp.setVisible(True)

	if k.name() == "renderName":

		if n["renderName"].value() == "custom name":
			n["customName"].setVisible(True)
		else:
			n["customName"].setVisible(False)

	if k.name() == "use_ocio":

		if n["use_ocio"].value():
			n["colorspace"].setEnabled(False)
			n["raw"].setEnabled(False)
			n["raw"].setValue(True)
		else:
			n["colorspace"].setEnabled(True)
			n["raw"].setEnabled(True)
			n["raw"].setValue(False)

nuke.addKnobChanged(sb_autoRenderKnobChanged, nodeClass = "Write")
Esempio n. 15
0
def pv2_createCallbacks():
	import nuke
	nuke.addKnobChanged(pv2_UIKnobChanged, nodeClass = 'Group')
Esempio n. 16
0
 def start(self):
     self.selectedNodes = nuke.selectedNodes()
     nuke.addKnobChanged(self.run)
     self.gangModifierRunning = True
     yl.info('gangModifyer is started')
Esempio n. 17
0
    global defaultHighlight
    multiSelect = not multiSelect
    if multiSelect:
        status = 'on'
        # make the SelectedColor a gross red
        nuke.toNode('preferences').knob('SelectedColor').setValue(4278190335)
    else:
        status = 'off'
        nuke.toNode('preferences').knob('SelectedColor').setValue(
            defaultHighlight)
    nuke.message('Multisection Modification is turned ' + status)


nuke.menu('Nuke').addMenu('Script').addCommand('Multiselected Modification',
                                               "toggleMultSelect()", 'ctrl+m')
nuke.addKnobChanged(multiselectCallback)

######################################################################################################################################################
######################################################################################################################################################
import merge_transforms_v2
nuke.menu('Nuke').addMenu('Script').addCommand('merge transforms',
                                               'merge_transforms_v2.start()')

nuke.menu('Nuke').addMenu('Script').addCommand('loadOffline',
                                               'load_offline_references()',
                                               "Shift+v")

try:
    import shortcuteditor
    shortcuteditor.nuke_setup()
except Exception:
Esempio n. 18
0
                    continue

                # making sure it's a directory
                if os.path.isdir(
                        os.path.join(variationsDirectory, variationName)):
                    variations.append(variationName)

        variations.sort()
        node['uVariation'].setValues(variations)
        if variations:
            node['uVariation'].setValue(
                os.path.basename(currentVariationDiretory))

    # updating current variation
    elif knob.name() == "uVariation" and knob.values():
        currentFile = os.path.basename(node['file'].value())
        variationsBaseDirectory = os.path.dirname(
            os.path.dirname(node['file'].value()))
        variationDirectory = os.path.join(variationsBaseDirectory,
                                          knob.value())

        # validating if the variation directory exists
        if os.path.exists(variationDirectory):
            node['file'].setValue(os.path.join(variationDirectory,
                                               currentFile))


# registering callbacks
nuke.addOnCreate(onCreateReadNode, nodeClass="Read")
nuke.addKnobChanged(onReadNodeUpdate, nodeClass="Read")
Esempio n. 19
0
def revealInFinder():
	'''
	get filepath and reveal src in finder
	'''

	n = nuke.thisNode()
	k = nuke.thisKnob()
	if k.name() == "revealInFinder":
		f = n.knob("file").value()
		path = "/".join(f.split("/")[:-1])
		openFolder(path)

def addRevealButton():
	'''
	add custom tab in read node and add reveal button
	'''
	
	n = nuke.thisNode()
	rB = nuke.PyScript_Knob('revealInFinder', 'reveal in finder', '')
	cT = nuke.Tab_Knob("custom", "custom")
	n.addKnob(cT)
	n.addKnob(rB)

nuke.addOnUserCreate(addRevealButton, nodeClass = 'Read')
nuke.addKnobChanged(revealInFinder, nodeClass="Read")




Esempio n. 20
0
	myPanel = SearchReplacePanel.SearchReplacePanel()
	return myPanel.addToPane()
 
#THIS LINE WILL ADD THE NEW ENTRY TO THE PANE MENU
nuke.menu('Pane').addCommand('SearchReplace', addSRPanel)

# CREATE A READ NODE AND OPEN THE "DB" TAB
def customRead():
	n = nuke.createNode( 'Read' )
	n['PipeL'].setFlag( 0 )
	return n

nuke.menu( 'Nodes' ).addCommand( 'Image/ReadPipel', customRead, 'Shift+r' )

nuke.addOnUserCreate( nuk.general.read.createVersionKnobs, nodeClass='Read' )
nuke.addKnobChanged( nuk.general.read.updateVersionKnob, nodeClass='Read' )

nuke.addOnScriptLoad( nuk.general.read.checkVersions )
nuke.addOnScriptSave( nuk.general.read.checkVersions )
"""
import nuk.general.read
import nuke
nuke.removeOnScriptLoad(nuk.general.read.checkVersions)
nuke.removeOnScriptSave(nuk.general.read.checkVersions)
"""

def mergeColor():
	n = nuke.thisNode()
	k = nuke.thisKnob()
	if k.name() == "mix":
		v = k.value()
Esempio n. 21
0
def addPlus():
    try:
        This = nuke.selectedNode()
        nodeClass = This.Class()
        tab = nuke.Tab_Knob('plus', 'plus')
        check = This.knob('plus')
        if check is not None:
            print 'knobs already exists'
            pass
        else:
            if nodeClass == 'FrameHold':
                button = nuke.PyScript_Knob("STCF", "Set To Current Frame")
                This.addKnob(tab)
                This.addKnob(button)
                This.knob('first_frame').setValue(nuke.frame())
                This['STCF'].setCommand(
                    "pfh = nuke.thisNode().knob('first_frame').setValue(nuke.frame())"
                )

            elif nodeClass == 'Read':
                line1 = nuke.Text_Knob("PlusControl", "Plus Control")
                PRXbutton = nuke.PyScript_Knob("PRX", "Create proxy")
                OPNbutton = nuke.PyScript_Knob("OPN", "Open Directory")
                OPNbutton.setFlag(nuke.STARTLINE)
                rltvbutton = nuke.PyScript_Knob("rltv", "Relative")
                rltvbutton.setFlag(nuke.STARTLINE)
                obslbutton = nuke.PyScript_Knob("obsl", "obsolute")
                obslbutton.clearFlag(nuke.STARTLINE)

                This.addKnob(tab)
                This.addKnob(line1)
                This.addKnob(PRXbutton)
                This.addKnob(OPNbutton)
                This.addKnob(rltvbutton)
                This.addKnob(obslbutton)

                This['PRX'].setCommand('CreatePRX()')
                This['OPN'].setCommand('plusOpen()')
                This['rltv'].setCommand('make_relative()')
                This['obsl'].setCommand('make_obsolute()')

            elif nodeClass == 'Camera2':
                check = This.knob('plus')
                if check is not None:
                    pass
                else:
                    button = nuke.PyScript_Knob("BKUP", "Bake")
                    button2 = nuke.PyScript_Knob("stereoRig", "Stereo Rig")
                    button2.setFlag(nuke.STARTLINE)
                    for k in (tab, button, button2):
                        This.addKnob(k)
                    This['BKUP'].setCommand('BakeUnderParent()')
                    This['stereoRig'].setCommand('stereoRig()')

            elif nodeClass == 'CornerPin2D':
                button1 = nuke.PyScript_Knob("referenceF",
                                             "Set Refecence Frame")
                seperator = nuke.Text_Knob("Convert", "Convert")
                button2 = nuke.PyScript_Knob("CPMX", "CornerPin to Matrix")
                button3 = nuke.PyScript_Knob("MXCP", "Matrix to CornerPin")
                This.addKnob(tab)
                This.addKnob(button1)
                This.addKnob(seperator)
                This.addKnob(button2)
                This.addKnob(button3)
                This['referenceF'].setCommand('copyCurrent()')
                This['CPMX'].setCommand('CP_to_Matrix()')
                This['MXCP'].setCommand('Matrix_to_CP()')

            elif nodeClass == 'Write':
                line1 = nuke.Text_Knob("PlusControl", "Plus Control")
                OPNbutton = nuke.PyScript_Knob("OPN", "Open Directory")
                OPNbutton.setFlag(nuke.STARTLINE)
                rfwbutton = nuke.PyScript_Knob("rfw", "Read from write")
                rfwbutton.setFlag(nuke.STARTLINE)
                linkCheck = nuke.Boolean_Knob("lnk", "Link")
                linkCheck.clearFlag(nuke.STARTLINE)
                This.addKnob(tab)
                This.addKnob(line1)
                This.addKnob(OPNbutton)
                This.addKnob(rfwbutton)
                This.addKnob(linkCheck)
                This['OPN'].setCommand('plusOpen()')

                def lnkv():
                    if This['lnk'].value() == False:
                        This['rfw'].setCommand('PlusRFW()')
                    else:
                        This['rfw'].setCommand('PlusRFWLink()')

                nuke.addKnobChanged(lnkv, nodeClass="Write")

            elif nodeClass == 'ReadGeo2':
                line1 = nuke.Text_Knob("PlusControl", "Plus Control")
                OPNbutton = nuke.PyScript_Knob("OPN", "Open Directory")
                OPNbutton.setFlag(nuke.STARTLINE)
                rltvbutton = nuke.PyScript_Knob("rltv", "Relative")
                rltvbutton.setFlag(nuke.STARTLINE)
                obslbutton = nuke.PyScript_Knob("obsl", "obsolute")
                obslbutton.clearFlag(nuke.STARTLINE)

                This.addKnob(tab)
                This.addKnob(line1)
                This.addKnob(OPNbutton)
                This.addKnob(rltvbutton)
                This.addKnob(obslbutton)

                This['OPN'].setCommand('plusOpen()')
                This['rltv'].setCommand('make_relative()')
                This['obsl'].setCommand('make_obsolute()')

            elif nodeClass == 'Axis2':
                button = nuke.PyScript_Knob("BKUP", "Bake")
                for k in (tab, button):
                    This.addKnob(k)
                This['BKUP'].setCommand('BakeUnderParent()')

            else:
                print "\nThere aren't any control knobs available for this class "
    except:
        print "no node selected"
Esempio n. 22
0
def pv2_createCallbacks():
	import nuke
	nuke.addKnobChanged(pv2_UIKnobChanged, nodeClass = 'Group')
Esempio n. 23
0
        'plus',
        'minus',
        'multiply',
        'hypot',
        'color-dodge',
        'color-burn',
        'average',
        'geometric',
        'overlay',
        'soft-light',
    ]

    if k:
        if k.name() == 'operation':
            if k.value() in rgbOnly:
                n['output'].setValue('rgb')
            else:
                n['output'].setValue('rgba')
    else:
        if n['operation'].value() in rgbOnly:
            n['output'].setValue('rgb')
        else:
            n['output'].setValue('rgba')


#-------------------------------------------------------------------------------
#-Adding Callbacks
#-------------------------------------------------------------------------------

nuke.addKnobChanged(ch_merge_out, nodeClass='Merge2')
Esempio n. 24
0
    # not sure which would be more effecient,
    # probably removing/adding callback?
    global multiSelect
    global defaultHighlight
    multiSelect = not multiSelect
    if multiSelect:
        status = 'on'
        # make the SelectedColor a gross red
        nuke.toNode('preferences').knob('SelectedColor').setValue(4278190335)
    else:
        status = 'off'
        nuke.toNode('preferences').knob('SelectedColor').setValue(defaultHighlight)
    nuke.message('Multisection Modification is turned '+status)

nuke.menu('Nuke').addMenu('Script').addCommand( 'Multiselected Modification', "toggleMultSelect()", 'ctrl+m')
nuke.addKnobChanged(multiselectCallback)


######################################################################################################################################################
######################################################################################################################################################
import merge_transforms_v2
nuke.menu('Nuke').addMenu('Script').addCommand( 'merge transforms', 'merge_transforms_v2.start()')



nuke.menu('Nuke').addMenu('Script').addCommand( 'loadOffline', 'load_offline_references()', "Shift+v")


try:
    import shortcuteditor
    shortcuteditor.nuke_setup()
Esempio n. 25
0
        subprocess.check_call(['explorer', path])


def revealInFinder():
    '''
	get filepath and reveal src in finder
	'''

    n = nuke.thisNode()
    k = nuke.thisKnob()
    if k.name() == "revealInFinder":
        f = n.knob("file").value()
        path = "/".join(f.split("/")[:-1])
        openFolder(path)


def addRevealButton():
    '''
	add custom tab in read node and add reveal button
	'''

    n = nuke.thisNode()
    rB = nuke.PyScript_Knob('revealInFinder', 'reveal in finder', '')
    cT = nuke.Tab_Knob("custom", "custom")
    n.addKnob(cT)
    n.addKnob(rB)


nuke.addOnUserCreate(addRevealButton, nodeClass='Read')
nuke.addKnobChanged(revealInFinder, nodeClass="Read")
Esempio n. 26
0
    # batch
    batch = nuke.PyScript_Knob("batch", "Batch", "batch.batch()")
    batch.setFlag(nuke.STARTLINE)
    node.addKnob(batch)

    node['file'].setEnabled(False)
    node['lock'].setValue(1)


''' write_knobChanged
    ---------------------------------------------------------------------------------------------------------------------------- '''


def write_knobChanged():
    node = nuke.thisNode()
    knob = nuke.thisKnob()

    if knob.name() == "lock":
        if knob.value() == 1:
            node['file'].setEnabled(False)
        else:
            node['file'].setEnabled(True)


# add callback to execute this every time a Write node is created
nuke.addOnUserCreate(write_addKnobs, nodeClass="Write")
nuke.addKnobChanged(write_knobChanged, nodeClass="Write")
''' load plugins
    ---------------------------------------------------------------------------------------------------------------------------- '''
loadPlugins.main()
def _cb(name):
    pass


def _cbk(name):
    pass


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"))
nuke.addRenderProgress(_cb, ("renderProgress"))
nuke.addFilenameFilter(lambda s: nuke.tprint("filenameFilter('" + s + "')"))

# 	nuke.load("Reload"); reloadSpecific("Franklin", "F_callbackTrace")

# else:
# 	val = True
# 	menubar = nuke.menu("Nuke")
# 	m = menubar.addMenu("Franklin",  "franklin.png")
Esempio n. 28
0
def setup_cryptomatte():
    nuke.addKnobChanged(lambda: cryptomatte_knob_changed_event(
        nuke.thisNode(), nuke.thisKnob()),
                        nodeClass='Cryptomatte')
Esempio n. 29
0
                return
        # CREATE PANEL
        p = assetManager.NkPanel( nkScripts )
        # ADJUST SIZE
        p.setMinimumSize( 200, 200 )

        # IF PANEL WAS CONFIRMED AND A NUKE SCRIPT WAS SELECTED, OPEN IT
        if p.showModalDialog():
                if p.selectedScript:
                        nuke.scriptOpen( p.selectedScript )

# ADD CALLBACKS
nuke.addOnScriptSave( assetManager.checkScriptName )
nuke.addOnUserCreate( nkPanelHelper, nodeClass='Root')
nuke.addOnUserCreate( assetManager.createVersionKnobs, nodeClass='Read' )
nuke.addKnobChanged( assetManager.updateVersionKnob, nodeClass='Read' )
nuke.addBeforeRender( assetManager.createOutDirs, nodeClass='Write' )
nuke.knobDefault( 'Write.beforeRender', 'assetManager.createOutDirs()')
### END ASSET MANAGEMENT SETUP ###


### BEGIN RENDER SETUP ###
m = menubar.addMenu("Render")
m.addCommand("Create Paths", "createPaths()")
#m.addCommand("Fix Paths", "fixPath.fixPath()")
## Uncomment this if RUSH is used
#m.addCommand("Send2Rush", "s2r.Nuke2Rush()")

### END RUSH SETUP ###

Esempio n. 30
0
import nuke

prefs = nuke.toNode('preferences')
grid_width = prefs['GridWidth'].getValue()
grid_height = prefs['GridHeight'].getValue()

def resize_to_grid():
    n = nuke.thisNode();
    k = nuke.thisKnob();
    if knob_to_grid(k, 'bdwidth', grid_width) or knob_to_grid(k, 'bdheight', grid_height):
        nuke.autoplaceSnap(n)

def knob_to_grid(knob, knob_name, grid_value):
    if knob.name() == knob_name:
        value = knob.getValue()
        base = 2 * grid_value
        new_value = int(base * round(float(value) / base))
        knob.setValue(new_value)
        return True
    return False

nuke.addKnobChanged(resize_to_grid, nodeClass = 'BackdropNode')
Esempio n. 31
0
        def __init__(self):
            nukescripts.PythonPanel.__init__(
                self, "Scale the distance between selected nodes",
                'justin-vfx.com')
            self.setMinimumSize(500, 150)

            self.uniform = nuke.Boolean_Knob('uniform', 'uniform scale')
            self.uniform.setValue(True)

            self.push = nuke.Boolean_Knob('push',
                                          'push other nodes when scaling up')
            self.push.setValue(False)
            self.push.clearFlag(nuke.STARTLINE)
            self.scale = nuke.Double_Knob("scale", "scale")
            self.scale.setRange(0, 10)
            self.scale.setValue(1)

            self.scaleX = nuke.Double_Knob("scalex", "width")
            self.scaleX.setRange(0, 10)
            self.scaleX.setValue(1)
            self.scaleX.setVisible(False)

            self.scaleY = nuke.Double_Knob("scaley", "height")
            self.scaleY.setRange(0, 10)
            self.scaleY.setValue(1)
            self.scaleY.setVisible(False)

            self.addKnob(self.uniform)
            self.addKnob(self.push)
            self.addKnob(self.scale)
            self.addKnob(self.scaleX)
            self.addKnob(self.scaleY)
            self.addKnob(nuke.Text_Knob(''))

            self.XMaxFirstNeedToPush = True
            self.XMinFirstNeedToPush = True
            self.YMaxFirstNeedToPush = True
            self.YMinFirstNeedToPush = True
            self.nToPushXMaxOrigPos_dic = {}
            self.nToPushXMinOrigPos_dic = {}
            self.nToPushYMaxOrigPos_dic = {}
            self.nToPushYMinOrigPos_dic = {}
            self.origDic = {}
            self.n_dic = {}
            self.needToPush = False

            self.ops = {
                "+": operator.add,
                "-": operator.sub,
                "<": operator.lt,
                "<=": operator.le,
                ">": operator.gt,
                ">=": operator.ge
            }

            nodes = nuke.allNodes()
            self.selectedNodes = nuke.selectedNodes()

            for n in nodes:
                origXpos = n.xpos()
                origYpos = n.ypos()
                if n.Class() == 'BackdropNode':
                    self.n_dic[n] = [
                        origXpos + n['bdwidth'].value() / 2,
                        origYpos + n['bdheight'].value() / 2,
                        n['bdwidth'].value(), n['bdheight'].value()
                    ]
                else:
                    self.n_dic[n] = [
                        origXpos + n.screenWidth() / 2,
                        origYpos + n.screenHeight() / 2
                    ]

            nuke.addKnobChanged(self.knobChanged)
Esempio n. 32
0
import nuke
import nextVersion

nuke.menu("Nuke").addCommand('Scripts/nextVersion', 'nextVersion.nextVersion()')
nuke.addOnUserCreate(nextVersion.addCustomElements, nodeClass = "Write")
nuke.addKnobChanged(nextVersion.performCustomAction, nodeClass = "Write")
Esempio n. 33
0
def setLocal():
	
# path variables

	repo = '/mnt/karramba'
	home = '/home/tfx/job.local'
	
# clears the selection if smth was selected	
	for node in nuke.allNodes():
		node.setSelected(False)

# copies footage to local machine

	readList = [node.knob('file').value() for node in nuke.allNodes('Read')]
	

	for path in readList:
		
		fileDirList =[path.rsplit(os.sep,1)[0] + os.sep + img for img in os.listdir(path.rsplit(os.sep,1)[0]) if img[:len(path.rsplit(os.sep,1)[1].split('%')[0])] == path.rsplit(os.sep,1)[1].split('%')[0]]
		newPath = home + path.rsplit(os.sep, 1)[0].split(repo)[-1] + os.sep
		
		if not os.path.exists(newPath):
			os.makedirs(newPath)
		
		for img in fileDirList:
			if not os.path.isdir(img):
				shutil.copy(img, newPath)

#creates new read nodes and controller to switch controller between local and network
			
	for node in nuke.allNodes('Read'):
		
		node.setSelected(True)
		
		sw = nuke.createNode('Switch', inpanel=False)
		sw.setSelected(False)
		sw.knob('which').setExpression('locController.location')
		node.setSelected(True)
		nuke.nodeCopy('%context%')
		c = nuke.nodePaste('%context%')
		
		sw.setInput(0, c)
		sw.setInput(1, node)
		
		node.setYpos(node.ypos()-90)
		c.setYpos(node.ypos())
		c.setXpos(node.xpos()-150)
		
		c.setName(c.name() + 'Local')
		node.setName(node.name() + 'Network')
		
		c.knob('file').setValue(home + node.knob('file').value().split(repo)[-1])
		
		node.setSelected(False)
		c.setSelected(False)

	n =	nuke.createNode('NoOp')
	n.setName('locController')
	k = nuke.Double_Knob('location', 'location')
	k.setRange(0, 1)
	n.addKnob(k)
	n.knob('hide_input').setValue(True)
	n.setXpos(nuke.toNode(findHighestRead()).xpos() + 500)
	n.setYpos(nuke.toNode(findHighestRead()).ypos())
	n.setSelected(False)
	
	st = nuke.createNode('StickyNote', inpanel=False)
	st.setName('status')
	st.setXpos(n.xpos())
	st.setYpos(n.ypos()-50)
	st.knob('label').setValue('LOCAL')
	st.knob('note_font_size').setValue(35)

	nuke.addKnobChanged(switchStatus, nodeClass='NoOp')
            nuke.toNode('watermark_image')['file'].fromScript(
                '[value parent.wm_file]')
            n.end()
            n['w_text_knob'].setEnabled(False)
            n['wm_file'].setEnabled(True)

            n['tiles'].setValue(7.4)
            n['translate'].setValue([0, 0])
            n['rotate'].setValue(0)
            n['scale'].setValue(1)


#Adding callback
nuke.removeKnobChanged(knobChanged, nodeClass='dushyant_info_watermark_node')

nuke.addKnobChanged(knobChanged, nodeClass='dushyant_info_watermark_node')


def watermark_main(what, type, text, file, path):

    deselect()
    if len(what) == 0:
        nuke.message('Nothing selected')
        return
    for selected in what:
        if selected.Class() == 'Read':
            watermark_proc(selected, type, text, file, path)
        else:
            nuke.message('works only on read nodes, skipping %s' %
                         selected['name'].getValue())
    else:
            n.begin()

            nuke.toNode('watermark_image')['file'].fromScript('[value parent.wm_file]')
            n.end()
            n['w_text_knob'].setEnabled(False)
            n['wm_file'].setEnabled(True)

            n['tiles'].setValue(7.4)
            n['translate'].setValue([0, 0])
            n['rotate'].setValue(0)
            n['scale'].setValue(1)

#Adding callback
nuke.removeKnobChanged(knobChanged, nodeClass='dushyant_info_watermark_node')

nuke.addKnobChanged(knobChanged, nodeClass='dushyant_info_watermark_node')

def watermark_main(what, type, text, file, path):

    deselect()
    if len(what) == 0:
        nuke.message('Nothing selected')
        return
    for selected in what:
        if selected.Class() == 'Read':
            watermark_proc(selected, type, text, file, path)
        else:
            nuke.message( 'works only on read nodes, skipping %s' % selected['name'].getValue() )
    else:
        nuke.message('All done!')
Esempio n. 36
0
File: am_nuke.py Progetto: pixo/hk
    # Create main node    
    node_asset = nuke.createNode ( "Camera2" )
    node_asset [ 'name' ].setValue ( "ReadCameraAsset" )
    node_asset [ 'read_from_file' ].setValue ( True )
    assetTab = nuke.Tab_Knob ( "Asset" )

    #Create and setup knobs
    node_asset.addKnob ( assetTab )
    repository = ( "network", "local" )
    krepo = nuke.Enumeration_Knob ( "repository", "repository", repository ) 
    repoup = "hkAssetUpdateAll ( nuke.thisNode () )"
    krepoup = nuke.PyScript_Knob ( "repositoryup", "Update", repoup )
    node_asset.addKnob ( krepo )
    node_asset.addKnob ( krepoup )
    
    for param in params :
        knob = nuke.Enumeration_Knob ( param, param, list () )
        node_asset.addKnob ( knob )

    #Update everything
    hkAssetUpdateAll ( node = node_asset )

#####################CALL BACK
#Add callback
for nclass in ( "Read","Write", "ReadGeo2", "Camera2" ):
    nuke.addKnobChanged ( hkAssetChanged , nodeClass= nclass )
    
def hkLoadAbc ():
    node = nuke.thisNode()
    node['file'].setValue(node['geofile'].getValue()) 
    # nuke.createScenefileBrowser( node['geofile'].value(), "ReadAsset" )