Friday, May 15, 2009

# create cylinder with nonuniform density of points

import maya.cmds as cmds
from math import *

from random import *

radius = 10
numCirc = 10

for n in range (0, numCirc, 1):
y = n #Number Of Elements By Y Axis
for i in range (0, 36, 1):
cmds.rotate( 0, 10*i, 0, pivot=(1, 0, 0) )
x = radius #create circle
z = randint (0,2)
myPoint = [x, y, z]
cmds.spaceLocator (p
= myPoint)

1 comment:

  1. Very nice! I like the way you created a circular disposition by skipping the sine or cosine functions and using radius and rotation.

    Just a little tweak, in your i loop, I would write:

    for i in range(0, 360/numCirc, 1):

    and then on the rotate command:

    cmds.rotate(0, numCirc*i,0, pivot=(1,0,0))

    This would make your code more flexible, by using the value of the initially defined numCirc variable to define the later transformations. In this way, if you ever need to change the number of circles, you have to make it only in the variable numCirc, and the script will take care of the rest.

    Always avoid hard-coding values which come from predefined variables!

    ReplyDelete