17 - 21 Creating Objects


The following source code allows us to program and spawn different shapes and allows us to change their properties such as width, radius and Height.  


import maya.cmds as cmds

cmds.polyCube( sx=10, sy=15, sz=5, h=20 )

#result is a 20 units height rectangular box

#with 10 subdivisions along X, 15 along Y and 20 along Z.

cmds.polyCube( sx=5, sy=5, sz=5 )

#result has 5 subdivisions along all directions, default size

# query the width of a cube

w = cmds.polyCube( 'polyCube1', q=True, w=True )


import maya.cmds as cmds

# Create a sphere, with 10 subdivisions in the X direction,

# and 15 subdivisions in the Y direction,

# the radius of the sphere is 20.

cmds.polySphere(sx=10, sy=15, r=20)

# Create a sphere, called "mySphere", on each direction there are 5 subdivisions.

cmds.polySphere( n='mySphere', sx=5, sy=5)

# Query the radius of the new sphere

r = cmds.polySphere( 'mySphere', q=True, sx=True ) 

Leave a comment

Log in with itch.io to leave a comment.