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):
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
40 """Convert a script containing NUKE 7 roto in one containing the old format."""
41 import os
42
43 os.environ["NUKE_CURVE_LONG_FORMAT"] = "1"
44 _convert(fromScript, toScript, overwrite)
45
46 os.environ.pop("NUKE_CURVE_LONG_FORMAT")
47
49 """Convert a script containing NUKE 6 roto in one containing the new format."""
50 import os
51
52
53 if "NUKE_CURVE_LONG_FORMAT" in os.environ:
54 os.environ.pop("NUKE_CURVE_LONG_FORMAT")
55 _convert(fromScript, toScript, overwrite)
56
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
62 os.environ["NUKE_CURVE_LONG_FORMAT"] = "1"
63 _convertDir(fromDir, toDir, matchPattern, overwrite)
64
65 os.environ.pop("NUKE_CURVE_LONG_FORMAT")
66
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
72
73 if "NUKE_CURVE_LONG_FORMAT" in os.environ:
74 os.environ.pop("NUKE_CURVE_LONG_FORMAT")
75 _convertDir(fromDir, toDir, matchPattern, overwrite)
76