Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
10 kB
3
Indexable
Never
try:
    from Scripts import openRV
    from Scripts import openMocha
except:
    import openRV
    import openMocha

nuke.load('InputProcess.py')
nuke.load('PerformanceTest.py')
nuke.load("VectorTracker.py")
nuke.load("AreaGradient.py")
nuke.load("setRotoLife.py")

#shortcuts
menubar = nuke.menu('Nuke')
menubar.addCommand("@;GetActiveViewerNode", "nuke.load('GetActiveViewerNode')", 'v')
menubar.addCommand('@;setFrameHold', 'nuke.load("setFrameHold")', '^h')
menubar.addCommand('@;channelMerge', 'createChannelMerge()', 'n')
menubar.addCommand('@;premult', 'nuke.createNode("Premult")', 'e')
menubar.addCommand('@;unpremult', 'nuke.createNode("Unpremult")', 'u')
menubar.addCommand("@;channelsToAlpha", "channelsToAlpha()", 'alt+a')
menubar.addCommand('@;SetFrameHold', 'nuke.load("setFrameHold")', '^h')

menubar.addCommand("@;showIP", "showIP()", 'alt+p')
menubar.addCommand("@;IPMirrorX", "IPMirrorX()", 'shift+o')
menubar.addCommand("@;IPMirrorY", "IPMirrorY()", 'shift+i')
menubar.addCommand("@;IPVersion", "IPVersion()", 'shift+v')
menubar.addCommand("@;IPReset", "IPReset()", 'shift+p')

menubar.addCommand("@;clearCache", 'nuke.memory("free"); nukescripts.clearAllCaches()', 'ctrl+shift+c')
menubar.addCommand("@;createDaily", "import mpc.nuke.hubNuke.hubNukeTools as hubNukeTools; hubNukeTools.createDaily(nuke.selectedNode())", 'ctrl+d')


menubar.addCommand("@;MergePlus", "createMerge('plus')", 'ctrl++')
menubar.addCommand("@;MergeFrom", "createMerge('from')", 'ctrl+-')
menubar.addCommand("@;MergeMultiply", "createMerge('multiply')", 'ctrl+*')
menubar.addCommand("@;MergeDivide", "createMerge('divide')", 'ctrl+/')

#Menubar items
menubar.addCommand("File/Restart Current Comp", "nuke.load('restartNuke')", 'ctrl+shift+q')
menubar.addCommand("Edit/Performance Profiling/Start Performance Timers", "nuke.startPerformanceTimers()")
menubar.addCommand("Edit/Performance Profiling/Stop Performance Timers", "nuke.stopPerformanceTimers()")
menubar.addCommand("Edit/Performance Profiling/Reset Performance Timers", "nuke.resetPerformanceTimers()")


def createMerge(operation):
    merge = nuke.createNode("Merge2")
    merge['operation'].setValue(operation)

def createChannelMerge():
    try:
        selected = nuke.selectedNode()
        cm = createGrizmo("ChannelMerge")
        cm['xpos'].setValue(selected.xpos())
        cm['ypos'].setValue(selected.ypos() + selected.screenHeight() + 6)
    except:
        createGrizmo("ChannelMerge")

def channelsToAlpha():
    for node in nuke.selectedNodes():
        if node.Class() == 'Merge2':
            node['Achannels'].setValue('Alpha')
            node['Bchannels'].setValue('Alpha')
            node['output'].setValue('Alpha')
        else:
            try:
                node['channels'].setValue('alpha')
            except:
                pass

def createGrizmo(nodeStr):
    dot = nuke.createNode("Dot")
    try:
        node = nuke.createNode(nodeStr)

        if node.Class() == 'Group':
            #create node
            node['xpos'].setValue(dot.xpos() - node.screenWidth()/2 + dot.screenWidth()/2)
            node['ypos'].setValue(dot.ypos())

            #disconnect group
            for i in range(node.inputs()):
                node.setInput(i, None)

            #set input group
            node.setInput(0, dot.input(0))

            #Connect dependancies
            connectedNodes = dot.dependent()
            for snode in range(len(connectedNodes)):
                dn = connectedNodes[snode]
                dotinput = [i for i in range(dn.inputs()) if dn.input(i) == dot]
                for input in range(len(dotinput)):
                    connectedNodes[snode].setInput(dotinput[input], node)
    except:
        pass

    #delete dot node
    nuke.delete(dot)

    try:
        return node
    except:
        pass

def shuffleCurrentViewerChannel():
    av = nuke.activeViewer().node()

    shuffle = nuke.createNode("Shuffle")
    shuffle['in'].setValue( av['channels'].value() )

    av['channels'].setValue('rgba')


toolbar = nuke.toolbar("Nodes")
userMenu = toolbar.addMenu("User", icon="Modify.png")

mpcMenu = userMenu.addMenu("mpc", "mpc.png")
mpcMenu.addCommand("UnparentLightMix", "nuke.load('UnparentLightMix')")
mpcMenu.addCommand("Open in reviewTool", "nuke.load('OpenRT')")
mpcMenu.addCommand("Refresh HubWrite", "nuke.load('RefreshHubWrite')")
mpcMenu.addCommand("Single Sample StereoConvergence", "with nuke.selectedNode():\n\tnuke.toNode('ScanlineRender2')['samples'].setValue(1)")
mpcMenu.addCommand("TypePaste", "nuke.load('TypePaste')")

MenuNukepedia = toolbar.addMenu("User/Nukepedia", "Nukepedia.png")
#pixelfudger
pixelFudgerMenu = MenuNukepedia.addMenu('Pixelfudger')
pixelFudgerMenu.addCommand( "PxF_Bandpass", "createGrizmo('PxF_Bandpass')")
pixelFudgerMenu.addCommand( "PxF_ChromaBlur", "createGrizmo('PxF_ChromaBlur')")
pixelFudgerMenu.addCommand( "PxF_Distort", "createGrizmo('PxF_Distort')")
pixelFudgerMenu.addCommand( "PxF_Erode", "createGrizmo('PxF_Erode')")
pixelFudgerMenu.addCommand( "PxF_Filler", "createGrizmo('PxF_Filler')")
pixelFudgerMenu.addCommand( "PxF_Grain", "createGrizmo('PxF_Grain')")
pixelFudgerMenu.addCommand( "PxF_HueSat", "createGrizmo('PxF_HueSat')")
pixelFudgerMenu.addCommand( "PxF_IDefocus", "createGrizmo('PxF_IDefocus')")
pixelFudgerMenu.addCommand( "PxF_KillSpill", "createGrizmo('PxF_KillSpill')")
pixelFudgerMenu.addCommand( "PxF_Line", "createGrizmo('PxF_Line')")
pixelFudgerMenu.addCommand( "PxF_MergeWrap", "createGrizmo('PxF_MergeWrap')")
pixelFudgerMenu.addCommand( "PxF_ScreenClean", "createGrizmo('PxF_ScreenClean')")
#xtools
xtoolsMenu = MenuNukepedia.addMenu('X_Tools')
xtoolsMenu.addCommand('X_Denoise', 'createGrizmo("X_Denoise")')
xtoolsMenu.addCommand('X_Distort', 'createGrizmo("X_Distort")')
xtoolsMenu.addCommand("X_Waveform", "createGrizmo('X_Waveform')")
xtoolsMenu.addCommand("X_Aton", "createGrizmo('X_Aton')")

MenuNukepedia.addCommand("Morph_Dissolve", "createGrizmo('Morph_Dissolve')")
MenuNukepedia.addCommand("TX_HueKeyer", "createGrizmo('TX_HueKeyer')")
MenuNukepedia.addCommand("DespillMadness", "createGrizmo('DespillMadness')")
MenuNukepedia.addCommand( "bm_OpticalGlow", "createGrizmo('bm_OpticalGlow')")
MenuNukepedia.addCommand( "bm_Lightwrap", "createGrizmo('bm_Lightwrap')")
#MenuNukepedia.addCommand( "EdgeExtend", "createGrizmo('EdgeExtend')")
MenuNukepedia.addCommand( "EdgeExtend2", "createGrizmo('EdgeExtend2')")

MenuNukepedia.addSeparator()

MenuNukepedia.addCommand( "aPMatte", "createGrizmo('aPMatte')")
MenuNukepedia.addCommand('Retime Camera', 'import RetimeCamera; RetimeCamera.create_RCPanel()')
MenuNukepedia.addCommand('CardToTrack', 'import cardToTrack; cardToTrack.card_to_track_wrapper()')
MenuNukepedia.addCommand("sb BakeWorldPosition", 'import sb_bakeWorldPosition; sb_bakeWorldPosition.sb_bakeWorldPosition()', '')

imageMenu = userMenu.addMenu('Image', 'ToolbarColor.png')
imageMenu.addCommand("Contrast", "createGrizmo('Contrast')")
imageMenu.addCommand("Multitone", "createGrizmo('Multitone')")
imageMenu.addCommand("Colorize", "createGrizmo('Colorize')")
imageMenu.addSeparator()
imageMenu.addCommand("BiRamp", "createGrizmo('BiRamp')")
imageMenu.addCommand("AreaGradient", "AG_MakeRenderFarmFriendly(createGrizmo('AreaGradient.gizmo'))")
imageMenu.addCommand("AverageValue", "createGrizmo('AverageValue')")

filterMenu = userMenu.addMenu('Filter', 'ToolbarFilter.png')
filterMenu.addCommand("Diffusion", "createGrizmo('Diffusion')")
filterMenu.addCommand("DirectionalBlur", "createGrizmo('DirectionalBlur')")
filterMenu.addCommand("CompoundBlur", "createGrizmo('CompoundBlur')")
filterMenu.addCommand("FireFlyKiller", "createGrizmo('FireFlyKiller')")
filterMenu.addCommand("SubPixelConvolve", "createGrizmo('SubPixelConvolve')")

keyingMenu = userMenu.addMenu('Keying', 'ToolbarKeyer.png')
keyingMenu.addCommand("Monochrome", "createGrizmo('Monochrome')")
keyingMenu.addCommand("ScreenClean", "createGrizmo('ScreenClean')")
keyingMenu.addCommand("IOKeyer", "createGrizmo('IOKeyer')")

expressionMenu = userMenu.addMenu('Expression', 'Expression.png')
expressionMenu.addCommand("UVMap", "createGrizmo('UVMap')")
expressionMenu.addCommand("UVtoVector", "createGrizmo('UVtoVector')")
expressionMenu.addSeparator()
expressionMenu.addCommand("AddFiltration", "createGrizmo('AddFiltration')")
expressionMenu.addCommand("GetFiltration", "createGrizmo('GetFiltration')")

TransformMenu = userMenu.addMenu('Transform', 'ToolbarTransform.png')
TransformMenu.addCommand("VectorTracker", "createGrizmo('VectorTracker.gizmo')")
TransformMenu.addCommand("ConcatTransform", "createGrizmo('ConcatTransform.gizmo')")
TransformMenu.addCommand("EdgeDistortion", "createGrizmo('EdgeDistortion')")

threeDMenu = userMenu.addMenu('3D', 'Cube.png')
threeDMenu.addCommand("QuickProject", "createGrizmo('QuickProject')")
threeDMenu.addCommand("OverscanProject3D", "createGrizmo('OverscanProject3D')")
threeDMenu.addCommand("ProjectPosition", "createGrizmo('ProjectPosition')")
threeDMenu.addCommand("ProjectRefPosition", "createGrizmo('ProjectRefPosition')")
threeDMenu.addCommand("WorldToCameraNormals", "createGrizmo('WorldToCameraNormals')")

DeepMenu = userMenu.addMenu('Deep', 'ToolbarDeep.png')
DeepMenu.addCommand("DeepDivMult", "createGrizmo('DeepDivMult')")

utilityMenu = userMenu.addMenu('Utility', 'Group.png')
nuke.load('JS_Backdrop.py')
utilityMenu.addCommand("InputProcess", "createIP()")
utilityMenu.addCommand("ShuffleAOV", "createGrizmo('ShuffleAOV')", '+h')
utilityMenu.addCommand("ShuffleControl", "nuke.load('ShuffleControl')")
utilityMenu.addCommand("BackdropPixels", "createGrizmo('BackdropPixels')")
utilityMenu.addCommand("GUISwitch", "createGrizmo('GUISwitch')")
utilityMenu.addCommand("PerformanceTest", "createGrizmo('PerformanceTest.gizmo')")
utilityMenu.addCommand("LayerCopy", "createGrizmo('LayerCopy')")
utilityMenu.addCommand("BokehSizeCalculator", "createGrizmo('BokehSizeCalculator')")
utilityMenu.addCommand("Shuffle Viewer Channel", "shuffleCurrentViewerChannel()")

externalMenu = userMenu.addMenu('External', 'DiskCache.png')
externalMenu.addCommand('Open in RV', 'openRV.run()')
externalMenu.addCommand('Open in Mocha', 'openMocha.run()')
externalMenu.addCommand("MochaAEtoNuke", 'nuke.load("MochaAEtoNuke")')

otherMenu = userMenu.addMenu('Other', 'ToolbarOther.png')
otherMenu.addCommand("DeviationMatte", "createGrizmo('DeviationMatte')")
otherMenu.addCommand("Looper", "createGrizmo('Looper')")