adding delete button to window


import maya.cmds

def Pyramid():

    

    pyramid_height = 20 

    

    for x in range(1,pyramid_height):   

        cmds.polyCube(w=1, h= 1, d= 1)

        cmds.move(x ,moveY = True)

        cmds.scale(pyramid_height,pyramid_height, scaleXZ = True)

        pyramid_height = pyramid_height - 1

        

        

def Pyramid_custom(slider_value):

    

    pyramid_height = cmds.intSlider(slider_value, query=True, value=True)

    

    for x in range(1,pyramid_height):   

        cmds.polyCube(w=1, h= 1, d= 1)

        cmds.move(x ,moveY = True)

        cmds.scale(pyramid_height,pyramid_height, scaleXZ = True)

        pyramid_height = pyramid_height - 1

        

        

def DeleteAll():

    cmds.select(all=True)

    cmds.delete()

#########ADDING A BUTTON###########################################################

    

window = cmds.window( title="Create a pyramid", iconName='Pyramid', widthHeight=(200, 55) )

cmds.columnLayout( adjustableColumn=True )

cmds.button( label='Create Pyramid',command = "Pyramid()"  )

slider = cmds.intSlider( min=1, max=100, value=0, step=1 )

cmds.button( label='Create Pyramid',command = "Pyramid_custom(slider)"  )

cmds.button( label='Delete', command='DeleteAll()' )

cmds.showWindow( window )

   

                

#######################################################


everything in bold above is the code added to create a delete button which deletes the pyramids that have been created.  when the button is pressed it selects everything that has been created in the scene and then deletes it.


this is done using the delete and select command in maya.

Leave a comment

Log in with itch.io to leave a comment.