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 else: 51 spec = "*.nk; *.gizmo" 52 s = nuke.getFilename("Import Script", spec, "", "script") 53 nuke.nodePaste(s) 54 except: 55 pass
56 57
58 -def export_nodes_as_script():
59 try: 60 if nuke.env['nc']: 61 nukeExt = ".nknc" 62 else: 63 nukeExt = ".nk" 64 s = nuke.getFilename("Export Nodes As Script", "*" + nukeExt, "", "script", "save", extension=nukeExt) 65 if s is not None: 66 nuke.nodeCopy(s) 67 except: 68 pass
69