







######### Excercise 03A
import maya.cmds as cmds
import random
import math
###### CURVE ######
# A) get all the cvsNames of a curve
allCvs = cmds.ls("curve1.cv[:]", fl=1)
# B) define move cvs randomly
def moveVertRandomly (allCvs, minimum, maximum):
if minimum>= maximum:
print "hello!"
# B.1) 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)
# C) move cvs randomly
moveVertRandomly (allCvs, 0, 17)
####### Nurbs Surface #######
# A) get all the vertices of the Nurbs
allCvs= cmds.ls("nurbsPlane1.cv[:][:]", fl=1)
# B) define move cvs in nurbsPlane randomly
def moveVertiRandomly(allCvs, minimum, maximum,x,y,z):
if minimum>= maximum:
print "hello!"
# B.1) 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)
# C) move dvs randomly
moveVertiRandomly (allCvs, 2, 18, 0,0,7)
####### Faces of a Polygon #######
# A) get all faces of a Polygon
allFaces= cmds.ls ("pCone1.f[:]", fl=1)
# B) define extrude faces of a polygon
def ExtrudeFacesRandom (allFaces, minimum, maximum):
if minimum>= maximum:
print "polygon"
# B.1 start a loop through all faces in y axix
else:
for face in allFaces:
ry= random.uniform(minimum, maximum)
cmds.polyExtrudeFacet(face, ltz=ry)
# C) extrude faces
ExtrudeFacesRandom(allFaces, 0,10)
####### Polygon Vertices #######
# A) get all vertices of a Polygon
allVertices= cmds.ls ("pPlane1.vtx[:]", fl=1)
# B) define movePolVertices
def movePolVert (allVertices, minimum, maximum):
if minimum>= maximum:
print "polygon"
# B.1 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)
# C) move Polygon Vertices
movePolVert(allVertices,1,7)
No comments:
Post a Comment