forked from lookbothways/vfxTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listMissingFrames_nuke_sd
94 lines (75 loc) · 3.24 KB
/
listMissingFrames_nuke_sd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#################################
#list missing frames
#by Sean Danischevsky 2015
#select a read or write node and copy a list of missing frames
#TODO: would like it to work by finding first and last
#rendered frames, not relying on node's start, end.
#would like to work on multiple reads/writes and proxy
#ignore files like /mnt/projects/oc/work/seand/000/060/nuke/render/precomp/rainBottomB/v006/oc_sc000_sh060_rainBottomB_v006.1088.png.2977.tmp
#and .nk files
#can I use glob/
import nuke
import os
#copy to clipboard
from PySide import QtGui
#testing= True
testing= False
def list_missing_frames():
missingFiles = []
completeFileName = ""
# first check if a node is selected and if so if it is a read node
selectedNodes = nuke.selectedNodes()
# either nothing or too much is selected
if (len(selectedNodes) != 1):
nuke.message("Please select a single node!")
return
#now we are sure one read node is selected, so go on.
node = selectedNodes[0]
try:
fileNameLong = node['file'].getValue()
#print fileNameLong
if node.Class() == 'Write' and not node['use_limit'].value():
startFrame = int(nuke.root()['first_frame'].value())
#print startFrame
endFrame = int(nuke.root()['last_frame'].value())
#print startFrame
else:
startFrame = int(node['first'].getValue())
#print startFrame
endFrame = int(node['last'].getValue())
#print startFrame
except:
return nuke.message("Please select a node with a file knob - e.g. a read node!")
# split the long file name with path to its subsections
pathName, fileNameShort = os.path.split(fileNameLong)
splitFileName = fileNameShort.split(".")
if (len(splitFileName) != 3):
nuke.message("File does not have the format name.number.ext.\nSearch the missing frames yourself :)")
return
fileName = splitFileName[0]
filePaddingOrg = splitFileName[1]
filePaddingLength = len((filePaddingOrg) % 0)
fileExtension = splitFileName[2]
# search for missing files in the sequence
for i in range(startFrame, endFrame+ 1):
# first build the string of the padded frameNumbers
frameNumber = str(i)
while(len(frameNumber) < filePaddingLength):
frameNumber = "0" + frameNumber
fileNameAndExt= fileName+ "."+ frameNumber+ "."+ fileExtension
completeFileName = os.path.join(pathName, fileNameAndExt)
#print completeFileName
if not os.path.isfile(completeFileName):
missingFiles.append(i)
if(len(missingFiles) == 0):
nuke.message("No missing files in range %d-%d!"%(startFrame,endFrame))
return
cleanedUpMissingFiles = str(nuke.FrameRanges(missingFiles))
print cleanedUpMissingFiles
nuke.message("In the range: " + str(startFrame) + "-" + str(endFrame) + "\nthe following files are missing:\n\n" + cleanedUpMissingFiles+'\n(Copied to clipboard).')
clipboard = QtGui.QApplication.clipboard()
clipboard.setText(cleanedUpMissingFiles) # set clipboard
return
#runs when testing:
if __name__ == "__main__":
list_missing_frames()