updated 2.24.16
|
|
ffxSpacingTool_v0.12.zip
# Tool for creating FumeFX Grids along a spline shape. Updated with FumeFX presets options. (needs at least FumeFX 2 to run) |
|
ffxSpacingTool_v0.11.zip
# Tool for creating FumeFX Grids along a spline shape. (works with FumeFX 1) |
|
mk_RenderElementRenamer_v0.1.zip
# Find and replace tool for render output & render element filenames |
preWrite.zip
# Checks for disabled vector blur nodes with inputs # also creates write node output directories if non-existent |
Create write node output directories if non-existent |
import os for node in nuke.allNodes('Write'): infile = node['file'].value() dirPath = infile.rsplit('/', 1)[0] if not os.path.isdir(dirPath) : os.makedirs(dirPath) |
Check if vector blur nodes with inputs are disabled |
vbNodes = [] for n in nuke.allNodes('VectorBlur'): connections = n.dependencies() if connections != [] and n['disable'].value() == True : vbNodes.append(n) if vbNodes != [] : if nuke.ask('Vector Blur Node(s) Disabled, Enable Node(s) with Connections?'): for vb in vbNodes: vb['disable'].setValue(False) |
Check read node inputs for missing frames |
#Returns the names of any read nodes with missing frames import os nodes = nuke.allNodes('Read') missingList = [] for node in nodes: fullFile = node['file'].value() filePath = fullFile.rsplit('/', 1)[0]+'/' filePrefix = fullFile.rsplit('/', 1)[-1].split('%')[0] fileRange = node['last'].value()-node['first'].value()+1 files = [] for entry in os.listdir(filePath): if filePrefix in entry : files.append(entry) if len(files) != fileRange : missingList.append(node.name()) if missingList != [] : nuke.message('Read Node(s) Missing Frame(s):'+'\n'+str(sorted(missingList))) else : print 'No Missing Frames' |
Create write nodes for each channel in selected multi-channel read nodes |
nodes = nuke.selectedNodes() for node in nodes: if node.Class() == 'Read': fullFile = node['file'].value() fileDir = fullFile.rsplit('/', 1)[0]+'/' file = fullFile.rsplit('/', 1)[1] filePrefix = file.split('%')[0] fileSuffix = file.split('%')[1] filePad = '%'+fileSuffix.split('.')[0] fileType = file.split('.')[-1] channels = node.channels() layers = list(set([channel.split('.')[0] for channel in channels])) for layer in layers: if layer == 'rgba': layers.remove('rgba') layers.append('Beauty') else: pass layers.sort() for layer in layers: layerIndex = layers.index(layer)+1 shuffleNode = nuke.nodes.Shuffle(label=layer, inputs=[node]) shuffleNode['in'].setValue(layer) writeNode = nuke.nodes.Write(label=layer, inputs=[node]) writeNode.setInput(0, shuffleNode) writeNode['file'].setValue(fileDir+layer+'/'+filePrefix+'.'+layer+'.'+filePad+'.'+fileType) writeNode['file_type'].setValue(fileType) writeNode['render_order'].setValue(layerIndex) else: pass |
Find the first and last frame of an image sequence |
import os loFrame = 999999999 hiFrame = 0 fileList = [] searchDir = 'C:/' for entry in os.listdir(searchDir): if os.path.isfile(searchDir+entry) : fileList.append(entry) ; # Add to list if entry is a file if fileList == [] : loFrame = 0 if not searchDir[-1] == '/' : searchDir += '/' for entry in os.listdir(searchDir): if os.path.isdir(searchDir+entry) : continue fA = entry.split('.') fB = fA[-2].split('_') try : num = int(fB[-1]) except : continue ; # not a file in a proper frame range if num < loFrame : loFrame = num if num > hiFrame : hiFrame = num print loFrame, hiFrame |
Find the file structure of an image sequence |
import os ''' Returns the most common filename prefix, sequence separator, padding, and file extension for the specified folder. ''' files = [] searchDir = 'C:/' version = 'v004' for entry in os.listdir(searchDir): if os.path.isfile(searchDir+entry) : files.append(entry) ; # Add to list if entry is a file common = os.path.commonprefix(files) if common.endswith(version) : filename = common else : if '.' in common : filename = common.rsplit('.', 1)[0] else : filename = common.rsplit('_', 1)[0] for entry in reversed(files): if common in entry : file = entry ; # Add to list if file contains common filename f = file.split('.') fileExt = f[-1] frNum = f[-2].split('_')[-1] filePad = '#'*len(frNum) if len(file.split('.')) == 2 : sep = '_' else : sep = '.' print filename, sep, filePad, fileExt |
Find sub-folders containing files |
import os searchDir = 'D:/renderoutput/' folderList = [] for entry in os.listdir(searchDir): folders = [] files = [] if os.path.isdir(searchDir+entry+'/') : folders.append(entry) for contents in folders: subFolder = os.listdir(searchDir+contents+'/') for index in subFolder: if os.path.isfile(searchDir+contents+'/'+index) : files.append(index) if files != [] : folderList.append(entry) ; # Add to list if folder contains files print folderList |
Select animated objects |
string $allObjects[]=`ls` ; select -cl; for($i=0;$i<`size($allObjects)`;$i++) if(`keyframe -q -keyframeCount $allObjects[$i]` != 0) select -tgl $allObjects[$i] ; |
Make selected objects matte objects |
string $MatteArray[] = `ls -sl`; for ($MatteObj in $MatteArray) { setAttr ($MatteObj + ".castsShadows") 0; setAttr ($MatteObj + ".receiveShadows") 0; setAttr ($MatteObj + ".primaryVisibility") 1; setAttr ($MatteObj + ".visibleInReflections") 0; setAttr ($MatteObj + ".visibleInRefractions") 0; setAttr ($MatteObj + ".miFinalGatherCast") 0; setAttr ($MatteObj + ".miFinalGatherReceive") 0; } |
Add custom attributes to selected objects |
string $addAttributes[] = `ls -sl`; for ($obj in $addAttributes) { addAttr -ln "__" -at "enum" -en "__:" ($obj); setAttr -e-channelBox true ($obj + ".__"); addAttr -ln "matA" -nn "Material A" ($obj); setAttr -e-keyable true ($obj + ".matA"); addAttr -ln "matB" -nn "Material B" ($obj); setAttr -e-keyable true ($obj + ".matB"); addAttr -ln "matC" -nn "Material C" ($obj); setAttr -e-keyable true ($obj + ".matC"); addAttr -ln "opacity" ($obj); setAttr -e-keyable true ($obj + ".opacity"); addAttr -ln "transparency" ($obj); } |
Copy material animation keys to custom attributes |
string $copyKeys[] = `ls -sl`; for ($obj in $copyKeys) { string $pasteList[] = `ls -sl`; hyperShade -smn; string $copyList[] = `ls -sl`; select -cl; for($i=0;$i<`size($copyList)`;$i++) if(`keyframe -attribute colorR -q -keyframeCount $copyList[$i]` != 0) { copyKey -attribute "colorR" $copyList[$i]; pasteKey -attribute "matB" $pasteList[$i]; copyKey -attribute "colorB" $copyList[$i]; pasteKey -attribute "matC" $pasteList[$i]; } select -cl; for($i=0;$i<`size($copyList)`;$i++) if(`keyframe -attribute transparencyR -q -keyframeCount $copyList[$i]` != 0) { copyKey -attribute "transparencyR" $copyList[$i]; pasteKey -attribute "transparency" $pasteList[$i]; } select $obj; } |
Add Expression To Reverse Material Opacity Value |
string $expMatA[] = `ls -sl`; for ($obj in $expMatA) { string $transExp[] = `ls -sl`; expression -s "matA = (-(matB + matC)) + 1;" -o $obj -ae 1 ; for($i=0;$i<`size($transExp)`;$i++) if(`keyframe -attribute transparency -q -keyframeCount $transExp[$i]` > 0) { expression -s "opacity = -(transparency) + 1;" -o $obj -ae 1 ; } } |
Assign a unique material to each object in selection |
//Only works after you've brought up the right mouse menu at least once string $assignMat[] = `ls -sl`; for ($obj in $assignMat) { shadingNode -asShader surfaceShader; string $storeMat[] = `ls -sl`; for ($mat in $storeMat) { sets -renderable true -noSurfaceShader true -empty -name ($mat + "SG"); connectAttr -f ($mat + ".outColor") ($mat + "SG.surfaceShader"); assignCreatedShader "surfaceShader" "" $mat $obj; sets -e -forceElement ($mat + "SG"); } } |