how to add a function to a button in a window
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.
jaden programming
More posts
- adding delete button to windowNov 28, 2022
- how to add a intslider to buttonNov 21, 2022
- create pyramid using a loop and then adding buttonNov 14, 2022
- simple commandsNov 14, 2022
- Creating a pyramidNov 14, 2022
- QuizNov 14, 2022
- how to code cubes that move in incrementsOct 17, 2022
- 10/10/2022Oct 17, 2022
Leave a comment
Log in with itch.io to leave a comment.