1
2
3 import nuke
4 import os
5
17
18
20 '''Create a Read node for a file selected from the file browser.
21 If a node is currently selected in the nodegraph and it has a 'file'
22 (or failing that a 'proxy') knob, the value (if any) will be used as the default
23 path for the file browser.'''
24
25
26 sel_node = None
27 default_dir = None
28 try:
29 sel_node = nuke.selectedNode()
30 except:
31 pass
32 if ( sel_node is not None ) and ( sel_node != '' ):
33 if 'file' in sel_node.knobs():
34 default_dir = sel_node['file'].value()
35 if (default_dir == None or default_dir == '') and 'proxy' in sel_node.knobs():
36 default_dir = sel_node['proxy'].value()
37
38
39
40 if default_dir == '': default_dir = None
41
42
43 files = nuke.getClipname( "Read File(s)", default=default_dir, multiple=True )
44 if files != None:
45 maxFiles = nuke.numvalue("preferences.maxPanels")
46 n = len(files)
47 for f in files:
48 isAbc = False
49 stripped = nuke.stripFrameRange(f)
50 nodeType = defaulttype
51 if isAudioFilename( stripped ):
52 nodeType = "AudioRead"
53 if isGeoFilename( stripped ):
54 nodeType = "ReadGeo2"
55 if isAbcFilename( stripped ):
56 isAbc = True
57 if isDeepFilename( stripped ):
58 nodeType = "DeepRead"
59
60
61
62
63 useInPanel = True
64 if (maxFiles != 0 and n > maxFiles):
65 useInPanel = False
66 n = n-1
67
68 if isAbc:
69 nuke.createScenefileBrowser( f, "" )
70 else:
71 try:
72 nuke.createNode( nodeType, "file {"+f+"}", inpanel = useInPanel)
73 except RuntimeError, err:
74 nuke.message(err.args[0])
75
77 filenameLower = filename.lower()
78 _, ext = os.path.splitext( filenameLower )
79
80 if ext in ['.fbx', '.obj']:
81 return True
82 else:
83 return False
84
86 filenameLower = filename.lower()
87 _, ext = os.path.splitext( filenameLower )
88
89 if ext in ['.abc']:
90 return True
91 else:
92 return False
93
95 filenameLower = filename.lower()
96 _, ext = os.path.splitext( filenameLower )
97
98 if ext in ['.dtex', '.dshd', '.deepshad']:
99 return True
100 else:
101 return False
102
104 filenameLower = filename.lower()
105 _, ext = os.path.splitext( filenameLower )
106
107 if ext in ['.wav', '.wave', '.aif', '.aiff']:
108 return True
109 else:
110 return False
111
143