Package nukescripts :: Module script
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.script

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2   
 3  import os.path 
 4   
 5  import nuke 
 6  import nukescripts 
 7   
 8  kCommandField = 'Command:' 
 9  last_cmd = '' 
10   
11 -def script_command(default_cmd):
12 global last_cmd 13 p = nuke.Panel("Nuke") 14 if (default_cmd != None and len(default_cmd) != 0): 15 use_cmd = default_cmd 16 else: 17 use_cmd = last_cmd 18 p.addScriptCommand(kCommandField, use_cmd) 19 p.addButton("Cancel") 20 p.addButton("OK") 21 result = p.show() 22 if result == 1: 23 last_cmd = p.value(kCommandField) 24 p.execute(kCommandField)
25 26 27
28 -def script_version_up():
29 """Adds 1 to the _v## at the end of the script name and saves a new version.""" 30 root_name = nuke.toNode("root").name() 31 (prefix, v) = nukescripts.version_get(root_name, "v") 32 if v is None: return 33 34 v = int(v) 35 nuke.scriptSaveAs(nukescripts.version_set(root_name, prefix, v, v + 1))
36 37
38 -def get_script_data():
39 activechans = nuke.Root.channels() 40 totchan = len(activechans) 41 42 root = nuke.toNode("root") 43 rez = root.knob("proxy").value() 44 45 numnodes = len(nuke.allNodes()) 46 47 chaninuse = totchan 48 chanleft = 1023-totchan 49 memusage = nuke.cacheUsage()/1024/1024 50 output = "Script : "+root.name()+"\n" 51 output = output+"Total nodes: "+str(numnodes)+"\n" 52 if rez: 53 output = output+"\nResolution : --PROXY--\n" 54 else: 55 output = output+"\nResolution : **FULL RES**\n" 56 output += "\nElements:\n"+nukescripts.get_reads("long") 57 58 output += "\nChannels in use: "+str(totchan)+"\n" 59 output += "Channels left: "+str(chanleft)+"\n" 60 output += "\nCache Usage: "+str(memusage)+" mb\n" 61 output += "\nChannel Data :\n" 62 63 layers = nuke.Root.layers() 64 for i in layers: 65 output += "\n"+i.name()+"\n" 66 channels = i.channels() 67 for j in channels: 68 if j in activechans: 69 output += "\t"+j+"\n" 70 71 return output
72 73
74 -def script_data():
75 nuke.display("nukescripts.get_script_data()", nuke.root())
76
77 -def script_directory():
78 return nuke.script_directory()
79