07/11/22
This session I was focused on creating a window where upon pressing a button on it would create a pyramid formed of cubes, with each cube that was stacked on top of the old one was smaller to get the shape of the pyramid correct. The code in order to make the window I wanted is as follows:
import maya.cmds
cmds.polyCube(width = 10, depth =20 )
cmds.move(0, height, 0
height = height+1
def DeleteAll():
cmds.select(all = True)
cmds.delete()
window = cmds.window( title="Pyramid", iconName="Short Name", widthHeight=(300, 135) )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label='Build Pyramid' )
cmds.button( label="Clear All", command = "DeleteAll()" )
cmds.button( label="Close", command=("cmds.deleteUI(\"" + window + "\", window=True)") )
cmds.setParent( '..' )
cmds.showWindow( window )
This would then create pyramids of one size when the button was pressed on the window, and the size could be changed by editing the code and entering new values for width and depth.
Leave a comment
Log in with itch.io to leave a comment.