TB1 Week 4
this week we start to learn more about functions and exped on the window GUI last week by creating a function first we did tasks on the website W3Schools help us to have a better understanding of how the function work we then made a function that had GUI that spwarned a cube that moved across the screen the code for this is:
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 )
we used the same code to make the window GUI but create a function that could be called upon when the button is pressed first you need to name the function so that the buttons knows what to call when the buttons is pressed, then we tell what we wanted to make a cube with "cube=cmds.polyCube()" then we define it with
for i in range(Animation_Range):
cmds.currentTime( (i+1)*10, edit=True )
cmds.setKeyframe(cube,v=i, at="translateX")
Range = 10
this set who long we want the animation and how far it will move when the code is executed
Programming for Animation
Status | In development |
Author | TheWigum |
More posts
- TB1 Week 9Dec 12, 2022
- TB1 Week 8Dec 12, 2022
- TB1 Week 7Dec 11, 2022
- TB1 Week 5Dec 11, 2022
- TB1 Week 3Dec 10, 2022
- TB1 Week 2Oct 10, 2022