TB1 Week 7


this week we started writing a script to make a pyramid in Maya using what we have learnt so far  the code I came up with was this:

import maya.cmds

def make_pyramid(range_of_pyramid):

 for X in range(range_of_pyramid):

            cmds.polyCube(d=range_of_pyramid,w=range_of_pyramid )

            cmds.move(X, moveY = True)

            range_of_pyramid-= 1

make_pyramid(5)

at first, the cube just stack on top of each other and not pyramid shape  until I added  "(d=range_of_pyramid,w=range_of_pyramid )" which changed the size of each cube  each time the loop happens  until 5 is  reached  as defined by  "make_pyramid(5)" we used the  window function  for last week to make the pyramid spawn with a click of a button  

import maya.cmds as cmds

def make_pyramid(Range_of_pyramid):

 for X in range(Range_of_pyramid):

            cmds.polyCube(d=Range_of_pyramid,w=Range_of_pyramid )

            cmds.move(X, moveY = True)

            Range_of_pyramid-= 1

make_pyramid(5)

window = cmds.window( title="Long Name", iconName='Short Name', widthHeight=(200, 55) )

cmds.columnLayout( adjustableColumn=True )

cmds.button( label='Make_pyramid', command= ('make_pyramid(Range_of_pyramid)'))

cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )

cmds.setParent( '..' )

cmds.showWindow( window )


but I could not get this to work for some reason  it did not work and just spawn the pyramid when executing the code and give no error