Advertisement
yaotungyu

clean tech blaast rnd

Jun 30th, 2020
1,509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. import fileTools.default as ft
  2. import os
  3. import json
  4.  
  5. jsondcoder = json.JSONDecoder()
  6. cmds.file(new=1,f=1)
  7. prod_path = ft.ez.path('products')
  8. 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])
  9. with open(ref_log,'r') as reflogfile:
  10.     reference_decode = jsondcoder.decode(reflogfile.read())
  11.  
  12.  
  13.  
  14. help(ft.ez.path)
  15. blastable_products = ['cameras','caches','ox_groom']
  16. for prod in blastable_products:
  17.     if prod =='cameras':
  18.         cams = os.listdir( os.path.join(prod_path,prod))
  19.         cams.sort()
  20.         print 'latest camera',cams[-1]
  21.         if cams[-1].endswith('.abc'):
  22.             abc_import_and_namespacerize(os.path.join(prod_path,prod,cams[-1]),'')
  23.     else:
  24.         assets = os.listdir( os.path.join(prod_path,prod))
  25.         for a in assets:
  26.             if reference_decode[a]['type']=='Character':
  27.                 exports = os.listdir(os.path.join(prod_path,prod,a))
  28.                 exports.sort()
  29.                 print 'latest export',exports[-1]
  30.                 if exports[-1].endswith('.abc'):
  31.                     abc_import_and_namespacerize(os.path.join(prod_path,prod,a,exports[-1]),a)
  32.                 if exports[-1].endswith('.ma'):
  33.                     cmds.file((os.path.join(prod_path,prod,a,exports[-1]),ns=a,i=1)
  34.  
  35.  
  36.  
  37.  
  38. def abc_import_and_namespacerize(path,ns):
  39.     pre_import = cmds.ls(assemblies=1)
  40.     abc_import = cmds.AbcImport(path, mode = 'import')
  41.     post_import = cmds.ls(assemblies=1)
  42.    
  43.     imported_roots = list(set(post_import).difference(pre_import))
  44.     if ns !='':
  45.         cmds.namespace(add=ns)
  46.         for item in [con for con in cmds.listConnections(abc_import) if cmds.nodeType(con)=='transform']+imported_roots:
  47.             cmds.rename(item,ns+':'+item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement