SHARE
TWEET

ox op create

yaotungyu Jun 2nd, 2020 (edited) 953 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def Ox_Create_Operator(target,operator,name=""):
  2.     '''
  3.   Some common operator to us:
  4.  
  5.   - OscillatorNode
  6.   '''
  7.     import maya.mel as mel
  8.     pre_create_op_list = cmds.ls(type=operator)
  9.     mel.eval('OxAddStrandOperator "'+target+'" '+operator)
  10.     post_create_op_list = cmds.ls(type=operator)
  11.     created_op = list(set(post_create_op_list).difference(pre_create_op_list))[0]
  12.     cmds.rename(created_op,name)
  13.    
  14. for h in cmds.ls(type='HairShape'):
  15.     ns = h.split(':')[0]
  16.     Ox_Create_Operator(h,'OscillatorNode',name = ns+'__'+h.split(':')[1].replace('GRMShape','OscillatorNode'))
  17.  
  18. for a in cmds.ls(sl=1):
  19.     grmshape = cmds.listRelatives(a,c=1,shapes=1)[0]
  20.     ns = grmshape.split(':')[0]
  21.     Ox_Create_Operator(grmshape,'OscillatorNode',name=grmshape.replace('GRMShape','OscillatorNode'))
  22. cmds.select(cmds.ls(type='OscillatorNode'))
  23. for a in cmds.ls(sl=1):
  24.     grmshape = cmds.listRelatives(a,c=1,shapes=1)[0]
  25.     Ox_Create_Operator(grmshape,'AnimationCacheNode',name=grmshape.replace('GRMShape','AnimationCacheNode'))
  26.  
  27. import fileTools.default as ft
  28. anim_cache_base = ft.ez.path('elems')+'/'+'ox_anm_caches'
  29. cmds.sysFile(anim_cache_base,md=1)
  30. tmin = cmds.playbackOptions(q=1,min=1)
  31. tmax = cmds.playbackOptions(q=1,max=1)
  32. for a in cmds.ls(type='AnimationCacheNode'):
  33.     cmds.setAttr(a+'.filePath',anim_cache_base+'/'+a.replace(":",'.')+'.abc',type='string')
  34.     cmds.OxRecordAnimation(a,startTime=tmin,endTime=tmax)
  35.  
  36. for a in cmds.ls(type='AnimationCacheNode'):
  37.     mel.eval('OxDeleteStrandOperator "'+a+'"')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top