Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """__________________
- Shape Gen
- Version_plant_Stage2
- cwisbg
- Brandon Gillespie
- 1/16/2012
- ______________________
- """
- from pymel.core import*
- import maya.cmds as mc
- import random as r
- import time
- # Get face locations
- def getFace(a):# a = selection, b = face array, c = face place array
- x = 0
- b = [] # array for selecting faces
- c = [] # array for face Locations
- for face in a.f:
- if face == a.f[0]:
- pass
- else:
- b.append(face) #add face to array
- select(b[x])
- mc.setToolTo('Move')
- c.append(mc.manipMoveContext('Move', q=True, p=True,m=2))
- select(cl=1)
- x += 1
- return b, c
- # For every face in selected object, duplicate selected object at face.
- def inctancer(a,b):# a= copy obj, b = location , returns list of duplicated objs
- z = 0
- x = 0
- c = []
- for place in b:
- randoTx = r.randint(1,5)
- randoTy = r.uniform(1,2)
- randoTx = r.randint(1,5)
- randoSx = .25#r.uniform(0,.1)
- randoRx = r.randint(0,360)
- randoRy = r.randint(0,360)
- randoRz = r.randint(0,360)
- refresh(cv=1)
- #cycleCheck(e=0)
- c.append(duplicate('dupObj', n ='{0}_copy_{1}'.format(a,x)))
- move(c[x][0],b[x][0],b[x][1],b[x][2], ls=1,a=1)
- normalConstraint(a,c[x][0] , w=1, aim = (0,1,0), u = (0,1,0), wut = "scene",n = 'tempNrml')
- delete('tempNrml')
- #move(c[x][0],0,0,0,os=1,r=1)
- #rotate(c[x][0],0,randoRy,0, os=1, r=1)
- scale(c[x][0],randoSx-z,randoSx-z,randoSx-z,r=1)
- x += 1
- z += .001
- return c
- #________________________________________________________________________________
- start = time.clock()
- sl = selected()
- x = 1
- for i in sl:
- print "on:",x,"of",len(sl)
- faceLocations = []
- level_1_faces = []
- level_1_faces, faceLocations = getFace(i)
- level_1 = inctancer(i,faceLocations)
- #scale(i, .8,.8,.8, r=1)
- #rotate(i, 45,45,45, r=1)
- zero = 0
- xx = 2
- zz = 1
- yy = 0
- x += 1
- for obj in level_1:
- ll = len(level_1)
- if zero == 0:
- polyUnite(obj[0],level_1[zz][0], n = 'obj_{0}'.format(x),ch=0)
- zero += 1
- yy += 1
- elif yy < ll-1:
- polyUnite('obj_{0}'.format(x),level_1[xx][0], n = 'obj_{0}'.format(x+1),ch=0)
- rename('obj_{0}'.format(x+1), 'obj_{0}'.format(x))
- xx += 1
- yy += 1
- """
- #___Duplicate level 2___
- x = 0
- level_1_len = len(level_1)
- z = 1
- for i in level_1:
- if x < level_1_len :
- print 'on lv2:', x, 'of', len(level_1)
- faceLocations2 = []
- level_2_faces = []
- level_2_faces, faceLocations2 = getFace(i[0])
- level_2 = inctancer(i,faceLocations2)
- z += 1
- zero = 0
- xx = 2
- zz = 1
- yy = 0
- for obj in level_2:
- ll = len(level_2)
- if zero == 0:
- polyUnite(obj[0],level_2[zz][0], n = 'obj_{0}'.format(x),ch=0)
- zero += 1
- yy += 1
- elif yy < ll-1:
- polyUnite('obj_{0}'.format(x),level_2[xx][0], n = 'obj_{0}'.format(x+1),ch=0)
- rename('obj_{0}'.format(x+1), 'obj_{0}'.format(x))
- xx += 1
- yy += 1
- zz += 1
- x += 1
- """
- elapsed = (time.clock() - start)
- print 'Took',elapsed, 'somethings'
Advertisement
Add Comment
Please, Sign In to add comment