Posted October 17, 2022 by jadenb432
import maya.cmds
Animation_Range = 10
def Create_Cube(increment):
Cube = cmds.polyCube()
cmds.move(increment, x = True)
for x in range(1,101,10):
Create_Cube(x)
cube = cmds.polyCube()
for i in range(Animation_Range):
cmds.currentTime( (i+1)*10, edit=True )
cmds.setKeyframe(cube,v=i, at="translateX")
window = cmds.window( title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label='Create Cube',command = "Create_Cube(10)" )
cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
cmds.setParent( '..' )
cmds.showWindow( window )
this piece of code allows you to add a function to a button in a window in maya and in this case the button says create cube so when you press the button the code linked to the button would run and therefore a cube would be created.