Wednesday, July 22, 2009

03A Cosmos Bedzra




import maya.cmds as cmds
import random
import math

##################################################
#Curve CVs
##################################################
# getting all CVs of the curve
allCvs = cmds.ls("curve1.cv[:]", fl=1)

# randomly moving CVs
def moveVertRandomly (allCvs, minimum, maximum):
if minimum>= maximum:
print "Dessau!"
# start a loop through all cvs
else:
for cv in allCvs:
rx = random.uniform(minimum, maximum)
ry = random.uniform(minimum, maximum)
rz = random.uniform(minimum, maximum)
cmds.move (rx,ry,rz,cv,r=2)

moveVertRandomly (allCvs, -5, 5)

##################################################
# Nurbs Surfaces CVs
##################################################
# getting vertices of the Nurbs surface
allCvs= cmds.ls("nurbsPlane1.cv[:][:]", fl=1)

# randomly moving Cvs of the Nurbs surface
def moveVertiRandomly(allCvs, minimum, maximum,x,y,z):
if minimum>= maximum:
print "Dessau!"
# start a loop through all cvs in z axis
else:
for i in allCvs:
x= 0
y= 0
z= random.uniform(minimum, maximum)
cmds.move (x,y,z,i,r=True)

moveVertiRandomly (allCvs, -1, 3, 0,0,1)

##################################################
# Faces of a polygon
##################################################
# getting all faces of Polygon
allFaces= cmds.ls ("pSolid1.f[:]", fl=1)

# extruding faces of the polygon
def ExtrudeFacesRandom (allFaces, minimum, maximum):
if minimum>= maximum:
print "Dessau"
# start a loop through all faces in y axis
else:
for face in allFaces:
ry= random.uniform(minimum, maximum)
cmds.polyExtrudeFacet(face, ltz=ry)

ExtrudeFacesRandom(allFaces, 0,2)

##################################################
# Polygon Vertices
##################################################
# getting all vertices of a Polygon
allVertices= cmds.ls ("pPlane1.vtx[:]", fl=1)

# randomly moving Polygon Vertices
def movePolVert (allVertices, minimum, maximum):
if minimum>= maximum:
print "Dessau"
# start a loop through vertices in z axis
else:
for e in allVertices:
rx= random.uniform (minimum, maximum)
ry= random.uniform (minimum, maximum)
rz= random.uniform (minimum, maximum)
cmds.move (rx,ry,rz,e,r=True)

movePolVert(allVertices,-1,1)

No comments:

Post a Comment