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 nuke.createNode( nodeType, "file {"+f+"}", inpanel = useInPanel)
72
74 filenameLower = filename.lower()
75 _, ext = os.path.splitext( filenameLower )
76
77 if ext in ['.fbx', '.obj']:
78 return True
79 else:
80 return False
81
83 filenameLower = filename.lower()
84 _, ext = os.path.splitext( filenameLower )
85
86 if ext in ['.abc']:
87 return True
88 else:
89 return False
90
92 filenameLower = filename.lower()
93 _, ext = os.path.splitext( filenameLower )
94
95 if ext in ['.dtex', '.dshd', '.deepshad']:
96 return True
97 else:
98 return False
99
101 filenameLower = filename.lower()
102 _, ext = os.path.splitext( filenameLower )
103
104 if ext in ['.wav', '.wave', '.aif', '.aiff']:
105 return True
106 else:
107 return False
108
140