TB1 Week 7


Began working on scripts which would generate pyramids in Maya automatically at the press of a button.

Initial attempt was made by using a function which would repeatedly create a cube at the correct place each time.

import maya.cmds

def Pyramid(width, height, depth):

   cmds.polyCube(w = width,h = height,d = depth)

   cmds.polyCube(w = width-1, h = height, d = depth-1)

   cmds.move(0,1,0)

   cmds.polyCube(w = width-2, h = height, d = depth-2)

   cmds.move(0,2,0)

   cmds.polyCube(w = width-3, h = height, d = depth-3)

   cmds.move(0,3,0)

Pyramid(4,1,4)

Afterwards, I managed to improve the script by making it use a for loop to make it generate the cubes, their scale and placement correctly each time.

import maya.cmds

def Pyramid(width, height):

    for x in range(1, width+1):

        cmds.polyCube(w = x, h = height, d = x)

        cmds.move(width, moveY = True)

        width = width-1

        

        

Pyramid(5,1)

Leave a comment

Log in with itch.io to leave a comment.