aboutsummaryrefslogtreecommitdiff
path: root/Core/Scripts/System/ART_StripFbxNamespace.py
blob: f223c58c51cd75c45cfa683f5e939d18237bf462 (plain) (blame)
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
import sys
import maya.standalone as std
std.initialize(name = 'python')
import maya.cmds as cmds
import maya.mel as mel
filename = sys.argv[1]

def stripNamespace(filename):

    try:
        #open the file
        cmds.loadPlugin("fbxmaya.mll")
        string = "FBXImportMode -v \"add\";"
        string += "FBXImport -file \"" + filename + "\""
        string += "FBXImportFillTimeline -v true"
        mel.eval(string)


        #remove the namespace
        cmds.namespace(setNamespace = "::")
        currentNamespaces = cmds.namespaceInfo(listOnlyNamespaces = True)

        restricted = ['UI', 'shared']

        for namespace in currentNamespaces:
            if namespace not in restricted:
                cmds.namespace(mv = (':' + namespace, ':'), force = True)
                cmds.namespace(removeNamespace = namespace)

        #re-export the file
        mel.eval("FBXExport -f \""+ filename +"\"")

        #exit
        std.uninitialize()

    except Exception, e:
        sys.stderr.write(str(e))
        sys.exit(-1)

stripNamespace(filename)