Advertisement
Guest User

Untitled

a guest
Oct 25th, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #ASSIGNMENT 4 Part 2
  2. import maya.cmds as cmd
  3.  
  4. def #working on this function
  5.  
  6. if cmd.ls(sl=True):
  7. parents = cmd.ls(sl=True)[-1]
  8. children = cmd.ls(sl=True)[:-1]
  9.  
  10. def match_translation():
  11. for obj in children:
  12. cmd.matchTransform(obj,parents,pos=True)
  13.  
  14. def match_orientation():
  15. for obj in children:
  16. cmd.matchTransform(obj,parents,rot=True)
  17.  
  18. def match_scale():
  19. for obj in children:
  20. cmd.matchTransform(obj,parents,scl=True)
  21.  
  22. def match_all_transforms():
  23. match_translation()
  24. match_orientation()
  25. match_scale()
  26.  
  27. def delete_history():
  28. for obj in cmd.ls(sl=True):
  29. cmd.delete(ch=True)
  30.  
  31. def center_pivot():
  32. for obj in cmd.ls(sl=True):
  33. cmd.xform(cp=True)
  34.  
  35. def freeze_translation():
  36. cmd.makeIdentity(a=True, t=True)
  37.  
  38. def freeze_orientation():
  39. cmd.makeIdentity(a=True, r=True)
  40.  
  41. def freeze_scale():
  42. cmd.makeIdentity(a=True, s=True)
  43.  
  44. def freeze_all_transforms():
  45. freeze_translation()
  46. freeze_orientation()
  47. freeze_scale()
  48.  
  49. if cmd.window("myWindow", ex=True):
  50. cmd.deleteUI("myWindow")
  51.  
  52. cmd.window("myWindow", t="Transformation Tool", w=300, h=300)
  53. cmd.columnLayout()
  54.  
  55. cmd.rowColumnLayout(nc=3)
  56. cmd.checkBox(w=100, h=50, al="center", l="Match T", bgc=(1,0,0), onc=match_translation)
  57. cmd.checkBox(w=100, h=50, l="Match R", bgc=(0,0,1), onc=match_orientation)
  58. cmd.checkBox(w=100, h=50, l="Match S", bgc=(0,1,0), onc=match_scale)
  59. cmd.setParent("..")
  60.  
  61. cmd.rowColumnLayout(nc=1)
  62. cmd.button(w=300, h=50, l="Match All Transforms", bgc=(1,1,1), c=match_all_transforms)
  63. cmd.setParent("..")
  64.  
  65. cmd.rowColumnLayout(nc=1)
  66. cmd.button(w=300, h=50, l="Zero Out All Transforms", bgc=(.5,.5,.5), c=match_all_transforms)
  67. cmd.setParent("..")
  68.  
  69. cmd.rowColumnLayout(nc=2)
  70. cmd.button(w=150, h=25, l="Delete History", bgc=(1,1,1), c=delete_history)
  71. cmd.button(w=150, h=25, l="Center Pivot", bgc=(1,1,1), c=center_pivot)
  72. cmd.setParent("..")
  73.  
  74. cmd.rowColumnLayout(nc=3)
  75. cmd.button(w=100, h=25, l="Freeze T", bgc=(1,0,0), c=freeze_translation)
  76. cmd.button(w=100, h=25, l="Freeze R", bgc=(0,0,1), c=freeze_orientation)
  77. cmd.button(w=100, h=25, l="Freeze S", bgc=(0,1,0), c=freeze_scale)
  78. cmd.setParent("..")
  79.  
  80. cmd.rowColumnLayout(nc=1)
  81. cmd.button(w=300, h=25, l="Freeze All Transforms", bgc=(1,1,1), c=freeze_all_transforms)
  82. cmd.setParent("..")
  83.  
  84. cmd.showWindow("myWindow")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement