-
Notifications
You must be signed in to change notification settings - Fork 1
/
3do2ma
executable file
·72 lines (53 loc) · 1.84 KB
/
3do2ma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python2_maya
import os, sys
import maya.cmds as cmds
import ma3do
import lecFormats
def parseArgs():
try:
inFile = sys.argv[1]
outDir = sys.argv[2]
except IndexError:
msg = "ERROR: you must specify one 3do file in and a directory "
msg += "to export to"
print >> sys.stderr, msg
sys.exit(1)
if not os.path.exists(outDir):
msg = "ERROR: the output directory must be an existing directory"
print >> sys.stderr, msg
sys.exit(1)
if not os.path.exists(inFile):
msg = "ERROR: the file '%' does not exist"%inFile
print >> sys.stderr, msg
sys.exit(1)
return (None, [inFile, outDir])
def main():
options, args = parseArgs()
modlBasename = os.path.basename(args[0])
modlName = os.path.splitext(modlBasename)[0]
# Build the path for the asset
assetDir = os.path.join(args[1], modlName)
if not os.path.exists(assetDir):
os.makedirs(assetDir)
# Build the place to export textures to
assetName = os.path.splitext(modlBasename)[0]
txDir = os.path.join(assetDir, 'textures')
if not os.path.exists(txDir):
os.makedirs(txDir)
# Export the textures
# os.system('/Users/eric/grim-proj/dump3dotx %s %s'%(args[0], args[1]))
# get the 3do
modl = lecFormats.ModlFile(args[0])
# Init maya
import maya.standalone
maya.standalone.initialize()
# build the model in memory
# @TODO: use an env var or relative path?
ma3do.buildModl(modl, os.path.abspath(txDir))
# Save the .ma file
maPath = os.path.abspath(os.path.join(assetDir, modlName+'.ma'))
cmds.file(rename = maPath)
cmds.file(save=True, f=True, options="v=0", type="mayaAscii")
print >> sys.stdout, "%s exported to %s"%(args[0], assetDir)
if __name__ == "__main__":
main()