Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. from maya import cmds
  2.  
  3. win_name = 'rig_blendShapeManager'
  4. text_scoll_list_name = 'bsm_tsl'
  5. slider_name = 'bsm_slider'
  6.  
  7. def blend_shape_manager_UI():
  8. if cmds.window(win_name, q=True, ex=True):
  9. cmds.deleteUI(win_name)
  10. cmds.window(win_name, t="Blend Shape Manager")
  11. cmds.columnLayout()
  12. cmds.textScrollList(
  13. text_scoll_list_name,
  14. sc=blend_shape_manager_connect,
  15. dcc=blend_shape_manager_activate,
  16. ams=True)
  17. cmds.floatSliderGrp(slider_name, field=True, minValue=0.0, maxValue=1.0, value=0)
  18. cmds.button(l="Refresh", c=blend_shape_manager_update)
  19. cmds.button(l="Reset", c=blend_shape_manager_reset)
  20. cmds.setParent("..")
  21. cmds.showWindow(win_name)
  22.  
  23.  
  24. def blend_shape_manager_update(*args):
  25. blend_shape_node = get_blend_shape_node()
  26. attributes = cmds.listAttr(blend_shape_node + ".weight", m=True)
  27. cmds.textScrollList(text_scoll_list_name, e=True, removeAll=True)
  28. cmds.textScrollList(text_scoll_list_name, e=True, append=attributes)
  29.  
  30. def blend_shape_mappnager_reset(*args):
  31. blend_shape_node = get_blend_shape_node()
  32. attributes = cmds.listAttr(blend_shape_node + ".weight", m=True)
  33. for attr in attributes:
  34. cmds.setAttr(blend_shape_node + '.' + attr, 0)
  35.  
  36. def get_blend_shape_node():
  37. selection = cmds.ls(sl=True)
  38. history_list = cmds.listHistory(selection[0])
  39. for node in history_list:
  40. if cmds.nodeType(node) == "blendShape":
  41. return node
  42.  
  43.  
  44. def blend_shape_manager_activate():
  45. blend_shape_node = get_blend_shape_node()
  46. selected = cmds.textScrollList(text_scoll_list_name, q=True, si=True)
  47. cmds.setAttr(blend_shape_node + '.' + selected[0], 1)
  48.  
  49. def blend_shape_manager_connect():
  50. blend_shape_node = get_blend_shape_node()
  51. selected = cmds.textScrollList(text_scoll_list_name, q=True, si=True)
  52. attributes = [blend_shape_node + '.' + attr for attr in selected]
  53. cmds.connectControl(slider_name, *attributes)
  54.  
  55. blend_shape_manager_UI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement