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

Source Code for Module nukescripts.importexport

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2  # -*- coding: utf-8 -*- 
 3   
 4  import nuke, os 
 5   
 6   
7 -def import_boujou():
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 # call a panel that asks the user for the camera txt file 29 try: 30 filename = nuke.getFilename("Boujou Text File", "*.txt") 31 32 # create the camera if one is not selected 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
46 -def import_script():
47 try: 48 if nuke.env['nc']: 49 spec = "*.nk; *.nknc; *.gizmo; *.gznc" 50 elif nuke.env['indie']: 51 spec = "*.nk; *.nkind; *.gizmo; *.gzind" 52 else: 53 spec = "*.nk; *.gizmo" 54 s = nuke.getFilename("Import Script", spec, "", "script") 55 nuke.nodePaste(s) 56 except: 57 pass
58 59
60 -def export_nodes_as_script():
61 try: 62 if nuke.env['nc']: 63 nukeExt = ".nknc" 64 elif nuke.env['indie']: 65 nukeExt = ".nkind" 66 else: 67 nukeExt = ".nk" 68 s = nuke.getFilename("Export Nodes As Script", "*" + nukeExt, "", "script", "save", extension=nukeExt) 69 if s is not None: 70 nuke.nodeCopy(s) 71 except: 72 pass
73