Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import fileTools.default as ft
- import os
- import json
- jsondcoder = json.JSONDecoder()
- cmds.file(new=1,f=1)
- prod_path = ft.ez.path('products')
- ref_log = os.path.join(os.path.join(ft.ez.path('logs'),'references'),sorted(os.listdir(os.path.join(ft.ez.path('logs'),'references')))[-1])
- with open(ref_log,'r') as reflogfile:
- reference_decode = jsondcoder.decode(reflogfile.read())
- help(ft.ez.path)
- blastable_products = ['cameras','caches','ox_groom']
- for prod in blastable_products:
- if prod =='cameras':
- cams = os.listdir( os.path.join(prod_path,prod))
- cams.sort()
- print 'latest camera',cams[-1]
- if cams[-1].endswith('.abc'):
- abc_import_and_namespacerize(os.path.join(prod_path,prod,cams[-1]),'')
- else:
- assets = os.listdir( os.path.join(prod_path,prod))
- for a in assets:
- if reference_decode[a]['type']=='Character':
- exports = os.listdir(os.path.join(prod_path,prod,a))
- exports.sort()
- print 'latest export',exports[-1]
- if exports[-1].endswith('.abc'):
- abc_import_and_namespacerize(os.path.join(prod_path,prod,a,exports[-1]),a)
- if exports[-1].endswith('.ma'):
- cmds.file((os.path.join(prod_path,prod,a,exports[-1]),ns=a,i=1)
- def abc_import_and_namespacerize(path,ns):
- pre_import = cmds.ls(assemblies=1)
- abc_import = cmds.AbcImport(path, mode = 'import')
- post_import = cmds.ls(assemblies=1)
- imported_roots = list(set(post_import).difference(pre_import))
- if ns !='':
- cmds.namespace(add=ns)
- for item in [con for con in cmds.listConnections(abc_import) if cmds.nodeType(con)=='transform']+imported_roots:
- cmds.rename(item,ns+':'+item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement