17/10/22
In this fourth week I started by completing the functions exercise on W3Schools and trying to understand how to create and name a function, alongside using arguments. After that, I used the following code to create a window in which held a button to spawn a cube and have it move in a straight line:
import maya.cmds
def Create_Animation(Animation_Range):
cube=cmds.polyCube()
for i in range(Animation_Range):
cmds.currentTime( (i+1)*10, edit=True )
cmds.setKeyframe(cube,v=i, at="translateX")
Range = 10
if cmds.window( "my_Window", exists = True):
cmds.deleteUI("my_Window")
window = cmds.window("my_Window", title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label='Create Animation' , c = "Create_Animation(Range)" )
cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
cmds.setParent('..')
cmds.showWindow( window )
Leave a comment
Log in with itch.io to leave a comment.