Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. import maya.cmds as mc
  2.  
  3. sel = mc.ls( selection=True )
  4. bbox = mc.exactWorldBoundingBox( sel )
  5.  
  6. centerX = (bbox[3] + bbox[0])/2
  7. centerY = (bbox[4] + bbox[1])/2
  8. centerZ = (bbox[5] + bbox[2])/2
  9.  
  10. LengthX = (bbox[3] - bbox[0])
  11. LengthZ = (bbox[5] - bbox[2])
  12.  
  13. center = [centerX, centerY, centerZ]
  14. print(center)
  15. print 'X:',centerX, 'Y:',centerY, 'Z:',centerZ
  16. print 'length', LengthX
  17.  
  18. def create_turntable(INstart, INtime, INlight, INcam):
  19. mc.deleteUI("CreateTurntable", window=True)
  20. print 'this', QINstart, QINtime, QINlight, QINcam
  21.  
  22. ccam = mc.camera( n='TurnTable_Cam' , fcp = 10000000, rot = (0,180,0))
  23. mc.scale(LengthX/10, LengthX/10, LengthX/10)
  24. print ccam[0]
  25.  
  26. cpath = mc.circle( n='Truntable_Path', c = center , nr = (0,1,0), r = LengthX )
  27. mc.xform(cp=1)
  28.  
  29. mpath = mc.pathAnimation (ccam[0], c = cpath[0], fm = True, f = True, fa = 'x', ua = "y", stu = QINstart, etu = 120)
  30.  
  31.  
  32.  
  33. if (mc.window('CreateTurntable', exists = True)):
  34.  
  35. mc.deleteUI('CreateTurntable')
  36.  
  37.  
  38. PyWindow1 = mc.window('CreateTurntable', title = 'Create a new Turntable', menuBar = True )
  39.  
  40. mc.window('CreateTurntable', edit = True , width = 500, height = 100, sizeable = False)
  41.  
  42. mc.rowColumnLayout (numberOfColumns = 1, width = 500, columnOffset = (1,'left' ,450), rowSpacing = (1,20), rowOffset = (1, 'top', 20))
  43.  
  44. mc.rowColumnLayout (numberOfColumns = 2, columnOffset = (1, 'right', 1), columnWidth = ((1, 200), (2, 100)), width = 300,
  45.  
  46. columnSpacing = ((1, 30),(2, 10)), rowSpacing = (1,20), rowOffset = (1, 'top', 10), p = PyWindow1)
  47.  
  48. mc.text (label = 'Animation starts at:')
  49. INstart = mc.intField (width = 30, value = mc.currentTime( query = True ), minValue = 0, maxValue = 1000)
  50. QINstart = mc.intField(INstart, q=1, v=1)
  51.  
  52. mc.text (label = 'Animation length:')
  53. INtime = mc.intField (width = 30, value = 120, minValue = 0, maxValue = 1000)
  54. QINtime = mc.intField(INtime, q=1, v=1)
  55.  
  56. mc.text (label = 'Create skydome light:')
  57. INlight = mc.checkBox( label = '', v=1 )
  58. QINlight = mc.checkBox(INlight, q=1, v=1)
  59.  
  60. mc.text (label = 'Go to camera view on creation:')
  61. INcam = mc.checkBox( label = '', v=1 )
  62. QINcam = mc.checkBox(INcam, q=1, v=1)
  63.  
  64.  
  65. mc.rowColumnLayout (numberOfColumns = 2, columnWidth = ((1, 150), (2, 150)), width = 500,
  66.  
  67. columnSpacing = ((1, 90),(2, 20)), rowOffset = (1, 'both', 20), p = PyWindow1)
  68.  
  69. mc.button( label='Create', bgc=(0, 1, 0), command=lambda x: create_turntable(QINstart, QINtime, QINlight, QINcam) )
  70. mc.button( label='Cancel', command=('mc.deleteUI("CreateTurntable" , window=True)') )
  71.  
  72. mc.showWindow( PyWindow1 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement