Skip to content

Instantly share code, notes, and snippets.

@Gi133
Created October 27, 2013 14:19
Show Gist options
  • Select an option

  • Save Gi133/7182689 to your computer and use it in GitHub Desktop.

Select an option

Save Gi133/7182689 to your computer and use it in GitHub Desktop.
Make an army of boxes!
# Cube Army Script for Maya
# Imports
import maya.cmds
# Parameters
rows = 10
columns = 10
spacing = 1
soldier_height = 2
# For every soldier in the army
for z_position in range(columns):
for x_position in range(rows):
# Create a cube
maya.cmds.polyCube(h=soldier_height)
# Position cube
maya.cmds.xform(t=(x_position + (x_position * spacing), soldier_height/2, z_position + (z_position * spacing)))
# Rename soldier from cube to something sensible.
maya.cmds.rename("Soldier")
# If it is the first cube in it's row then give it a hat.
if x_position == 0:
maya.cmds.polyCone()
maya.cmds.xform(t=(x_position + (x_position * spacing), soldier_height/2 + soldier_height, z_position + (z_position * spacing)))
# Group all the soldiers
maya.cmds.group( "Soldier*", n="Army" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment