def generateLog(self): if self.comment.value() != '': note = 'Notes\n\n' + self.comment.value( ) + '\n\n===================\n\n' else: note = self.comment.value() nodeInfo = '' a = {} b = [] c = [] for n in nuke.allNodes(): a[n.Class()] = 0 for n in nuke.allNodes(): c.append(n.Class()) for i in a: b.append(i) b.sort() for i in c: a[i] += 1 for i in b: nodeInfo = nodeInfo + '(' + str(a[i]) + ')' + ' ' + i + '\n' stats = nukescripts.get_script_data() logFile = open(self.file.value() + 'log.txt', 'w') logFile.write(note + nodeInfo + '\n\n\n\n' + stats) logFile.close()
def interface(self): # set up the new script name scriptName = os.path.basename(nuke.value('root.name')) date = datetime.date.today() formattedDate = '%s%02d%02d' % (date.year, int(date.month), int(date.day)) archivePath = 'z:/job/after_earth/prod/io/archive/%s/%s/' % (formattedDate, scriptName.replace('.nk','')) self.panel = nukescripts.PythonPanel('Archive script 1.01') self.file = nuke.File_Knob('Output','Output folder:') self.file.setValue(archivePath) self.panel.addKnob(self.file) self.scriptName = nuke.String_Knob('name','Script name:',scriptName) self.panel.addKnob(self.scriptName) self.log = nuke.Boolean_Knob('log','Generate log:',True) self.panel.addKnob(self.log) self.comment = nuke.Multiline_Eval_String_Knob('comment','Comments:') self.panel.addKnob(self.comment) result = self.panel.showModalDialog() self.scriptInfo = nukescripts.get_script_data() if result: self.convertGizmosToGroups() self.action()
def generateLog(self): if self.comment.value() != '': note = 'Notes\n\n' + self.comment.value() + '\n\n===================\n\n' else: note = self.comment.value() nodeInfo = '' a = {} b = [] c = [] for n in nuke.allNodes(): a[n.Class()] = 0 for n in nuke.allNodes(): c.append(n.Class()) for i in a: b.append(i) b.sort() for i in c: a[i] +=1 for i in b: nodeInfo = nodeInfo + '('+str(a[i])+')' + ' ' + i +'\n' stats = nukescripts.get_script_data() logFile = open(self.file.value()+ 'log.txt','w') logFile.write(note+nodeInfo+'\n\n\n\n'+stats) logFile.close()
def __init__(self, logArchive=False): self.logArchive = logArchive self.scriptInfo = nukescripts.get_script_data() self.init_interface() if self.show_interface(): self.action()