Package nuke :: Module rotopaint
[hide private]
[frames] | no frames]

Source Code for Module nuke.rotopaint

 1  """The Python interface for RotoPaint 
 2   
 3  Use help('_rotopaint') to get detailed help on the classes exposed here. 
 4  """ 
 5   
 6  from curveknob import * 
 7   
 8  import _rotopaint 
 9  from nuke import Hash 
10   
11   
12 -def _convert(fromScript, toScript, overwrite):
13 import nuke 14 nuke.scriptOpen(fromScript) 15 nuke.scriptSaveAs(toScript, overwrite) 16 nuke.scriptClose()
17
18 -def _convertDir(fromDir, toDir, matchPattern, overwrite):
19 import os 20 import re 21 22 if fromDir == toDir: 23 raise RuntimeError("Source and destination directories are the same") 24 if not os.path.isdir(fromDir): 25 raise RuntimeError("Source not a directory") 26 if not os.path.isdir(toDir): 27 raise RuntimeError("Destination not a directory") 28 if not os.access(toDir, os.W_OK): 29 raise RuntimeError("Destination directory is not writable") 30 31 pattern = re.compile(matchPattern) 32 for f in os.listdir(fromDir): 33 if (re.match(pattern, f)): 34 fromScript = os.path.join(fromDir, f) 35 toScript = os.path.join(toDir, f) 36 print "Converting %s to %s" % (fromScript, toScript) 37 _convert(fromScript, toScript, overwrite)
38
39 -def convertToNuke6(fromScript, toScript, overwrite = False):
40 """Convert a script containing NUKE 7 roto in one containing the old format.""" 41 import os 42 # This environment variable makes NUKE write out the old Roto format. 43 os.environ["NUKE_CURVE_LONG_FORMAT"] = "1" 44 _convert(fromScript, toScript, overwrite) 45 # Pop it from the environment so we don't affect other scripts 46 os.environ.pop("NUKE_CURVE_LONG_FORMAT")
47
48 -def convertToNuke7(fromScript, toScript, overwrite = False):
49 """Convert a script containing NUKE 6 roto in one containing the new format.""" 50 import os 51 # This environment variable makes NUKE write out the old Roto format so make 52 # sure it's disabled. 53 if "NUKE_CURVE_LONG_FORMAT" in os.environ: 54 os.environ.pop("NUKE_CURVE_LONG_FORMAT") 55 _convert(fromScript, toScript, overwrite)
56
57 -def convertDirectoryToNuke6(fromDir, toDir, matchPattern =".*\.nk", overwrite = False):
58 """Convert a directory containing NUKE 7 roto scripts in one containing the old format. 59 Note that the pattern is a regular expression.""" 60 import os 61 # This environment variable makes NUKE write out the old Roto format. 62 os.environ["NUKE_CURVE_LONG_FORMAT"] = "1" 63 _convertDir(fromDir, toDir, matchPattern, overwrite) 64 # Pop it from the environment so we don't affect other scripts 65 os.environ.pop("NUKE_CURVE_LONG_FORMAT")
66
67 -def convertDirectoryToNuke7(fromDir, toDir, matchPattern=".*\.nk", overwrite = False):
68 """Convert a directory containing NUKE 6 roto scripts in one containing the new format. 69 Note that the pattern is a regular expression.""" 70 import os 71 # This environment variable makes NUKE write out the old Roto format so make 72 # sure it's disabled. 73 if "NUKE_CURVE_LONG_FORMAT" in os.environ: 74 os.environ.pop("NUKE_CURVE_LONG_FORMAT") 75 _convertDir(fromDir, toDir, matchPattern, overwrite)
76