Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """___________________
- Shape Gen
- Version_0.7
- 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:
- 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 = .5
- x = 0
- c = []
- for place in b:
- randoTx = r.randint(1,5)
- randoTy = r.uniform(1,5)
- randoTx = r.randint(1,5)
- randoSx = r.uniform(.2,.4)
- randoRx = r.randint(0,360)
- randoRy = r.randint(0,360)
- randoRz = r.randint(0,360)
- refresh(cv=1)
- cycleCheck(e=0)
- c.append(duplicate(a, 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,.3,0,os=1,r=1)
- rotate(c[x][0],0,randoRy,0, os=1, r=1)
- # scale(c[x][0],scaler[0]-z,scaler[1]-z,scaler[2]-z,r=1)
- scale(c[x][0],randoSx,randoSx,randoSx,r=1)
- x += 1
- # z += .01
- 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)
- x += 1
- #___Duplicate level 2___
- x = 0
- xx = 0
- zz = 1
- z = 1
- for i in level_1:
- print 'on lv2:', x, 'of', len(level_1)
- faceLocations2 = []
- level_2_faces = []
- level_2_faces, faceLocations2 = getFace(i[0])
- level_2 = inctancer(i,faceLocations2)
- x += 1
- z += 1
- """
- for obj in level_2:
- print obj[0],level_2[zz][0]
- if xx == 0:
- polyUnite(obj[0],level_2[zz][0], n = 'ab',ch=0)
- xx += 1
- else:
- polyUnite('ab',level_2[zz][0], n = 'ab1',ch=1)
- rename('ab1', 'ab')
- print zz
- zz += 1
- ______________________________________
- for cube in level_2:
- print level_2[0][0],cube[0]
- if x == 0:
- polyUnite(cube[0],level_2[xx][0], n='ab',ch = 0)
- else:
- polyUnite('ab',level_2[xx][0], n='ab1',ch = 0)
- rename('ab1','ab')
- x += 1
- xx += 1
- polyUnite -ch 1 nt_Transform_u_pCube2_copy_4____copy_2 nt_Transform_u_pCube2_copy_4____copy_1
- nt_Transform_u_pCube2_copy_4____copy_4 nt_Transform_u_pCube2_copy_4____copy_5
- """
- print 'done'
- elapsed = (time.clock() - start)
- print 'Took',elapsed, 'somethings'
- """
- cl = len(c)-1
- cl2= cl - 1
- cl3 = 9
- x = 0
- xx = 1
- for cube in level_2:
- print level_2[0][0],cube[0]
- if x == 0:
- polyUnite(cube[0],level_2[xx][0], n='ab',ch = 0)
- else:
- polyUnite('ab',level_2[xx][0], n='ab1',ch = 0)
- rename('ab1','ab')
- x += 1
- xx += 1
- """
Advertisement
Add Comment
Please, Sign In to add comment