Last active
October 22, 2015 11:45
-
-
Save thomashope/6ae71475a471de58d7c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
# what to call the army | |
army_name = "Toms_dangerous_cubes" | |
cmds.group(empty=True, name=army_name) | |
# how many rows and columns the army should have | |
rows = 5; | |
cols = 5; | |
# execute this line individualy to get more information in the output pane | |
cmds.help("polyCube") | |
for z_pos in range(rows): | |
for x_pos in range(cols): | |
# create a cube and set the dimensions | |
object = cmds.polyCube(width=0.8, | |
height=2, | |
depth=0.8) | |
# place the 'soldiers' so the army is centered at the origin | |
cmds.xform(t=(x_pos - width/2, | |
1, | |
z_pos - depth/2)) | |
# set the new name of the soldier based on it's position in the formation | |
new_name = "soldier_" + str(x_pos) + "_" + str(z_pos) | |
# edit the name of previously made object | |
# (you could also just use the -name flag when creating it | |
cmds.rename(object[0], new_name) | |
cmds.group(new_name, parent=army_name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment