Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as mc
- sel = mc.ls( selection=True )
- bbox = mc.exactWorldBoundingBox( sel )
- centerX = (bbox[3] + bbox[0])/2
- centerY = (bbox[4] + bbox[1])/2
- centerZ = (bbox[5] + bbox[2])/2
- LengthX = (bbox[3] - bbox[0])
- LengthZ = (bbox[5] - bbox[2])
- center = [centerX, centerY, centerZ]
- print(center)
- print 'X:',centerX, 'Y:',centerY, 'Z:',centerZ
- print 'length', LengthX
- def create_turntable(INstart, INtime, INlight, INcam):
- mc.deleteUI("CreateTurntable", window=True)
- print 'this', QINstart, QINtime, QINlight, QINcam
- ccam = mc.camera( n='TurnTable_Cam' , fcp = 10000000, rot = (0,180,0))
- mc.scale(LengthX/10, LengthX/10, LengthX/10)
- print ccam[0]
- cpath = mc.circle( n='Truntable_Path', c = center , nr = (0,1,0), r = LengthX )
- mc.xform(cp=1)
- mpath = mc.pathAnimation (ccam[0], c = cpath[0], fm = True, f = True, fa = 'x', ua = "y", stu = QINstart, etu = 120)
- if (mc.window('CreateTurntable', exists = True)):
- mc.deleteUI('CreateTurntable')
- PyWindow1 = mc.window('CreateTurntable', title = 'Create a new Turntable', menuBar = True )
- mc.window('CreateTurntable', edit = True , width = 500, height = 100, sizeable = False)
- mc.rowColumnLayout (numberOfColumns = 1, width = 500, columnOffset = (1,'left' ,450), rowSpacing = (1,20), rowOffset = (1, 'top', 20))
- mc.rowColumnLayout (numberOfColumns = 2, columnOffset = (1, 'right', 1), columnWidth = ((1, 200), (2, 100)), width = 300,
- columnSpacing = ((1, 30),(2, 10)), rowSpacing = (1,20), rowOffset = (1, 'top', 10), p = PyWindow1)
- mc.text (label = 'Animation starts at:')
- INstart = mc.intField (width = 30, value = mc.currentTime( query = True ), minValue = 0, maxValue = 1000)
- QINstart = mc.intField(INstart, q=1, v=1)
- mc.text (label = 'Animation length:')
- INtime = mc.intField (width = 30, value = 120, minValue = 0, maxValue = 1000)
- QINtime = mc.intField(INtime, q=1, v=1)
- mc.text (label = 'Create skydome light:')
- INlight = mc.checkBox( label = '', v=1 )
- QINlight = mc.checkBox(INlight, q=1, v=1)
- mc.text (label = 'Go to camera view on creation:')
- INcam = mc.checkBox( label = '', v=1 )
- QINcam = mc.checkBox(INcam, q=1, v=1)
- mc.rowColumnLayout (numberOfColumns = 2, columnWidth = ((1, 150), (2, 150)), width = 500,
- columnSpacing = ((1, 90),(2, 20)), rowOffset = (1, 'both', 20), p = PyWindow1)
- mc.button( label='Create', bgc=(0, 1, 0), command=lambda x: create_turntable(QINstart, QINtime, QINlight, QINcam) )
- mc.button( label='Cancel', command=('mc.deleteUI("CreateTurntable" , window=True)') )
- mc.showWindow( PyWindow1 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement