1
2
3
4 import nuke, os
5
6
8 '''
9 Nuke 5.0 Py import_boujou. Demonstrates the use of addKnob.
10
11 Function called from the "import Boujou camera track" user knob of a
12 Boujou Camera gizmo.
13
14 read data from a Boujou text file:
15 format is: FRAME TX TY TZ RX RY RZ VFOV
16 this version will read fewer columns
17
18 modified by Frank Rüter June 30th 2006 to work with Nuke 4.5
19
20 Instead of writing out an obj like the old version this one creates
21 lowres cylinders for each point found in your boujou export. Those
22 are stuffed into a group which is hooked up to a render node along
23 with the resulting camera. It has size, colour and render
24 parameters to control those proxies. Keep in mind that there is a
25 limit for scene nodes of 1000 inputs so try to keep your point
26 export from Boujou below that ;).
27 '''
28
29 try:
30 filename = nuke.getFilename("Boujou Text File", "*.txt")
31
32
33 newCam = nuke.selectedNode();
34 if newCam.Class() != "Camera":
35 newCam = nuke.Camera()
36
37 newCam.knob("label").setValue("BoujouCamera\n"+filename)
38 file = open(filename, "r")
39 for line in file:
40 pass
41
42 except:
43 pass
44
45
47 try:
48 if nuke.env['ple']:
49 spec = "*.nk; *.nkple; *.gizmo; *.gzple"
50 else:
51 spec = "*.nk; *.gizmo"
52 s = nuke.getFilename("Import Script", spec, "", "script")
53 nuke.nodePaste(s)
54 except:
55 pass
56
57
59 try:
60 if nuke.env['ple']:
61 nukeExt = ".nkple"
62 else:
63 nukeExt = ".nk"
64 s = nuke.getFilename("Export Nodes As Script", "*" + nukeExt, "", "script", "save")
65 (root, ext) = os.path.splitext(s)
66 if not ext:
67 s += nukeExt
68 elif ext == ".nk" and ext != nukeExt:
69 s = s[0:-3] + nukeExt
70 if os.path.exists(s):
71 if not nuke.ask("Overwrite existing " + s + " ?"):
72 return
73 nuke.nodeCopy(s)
74 except:
75 pass
76