Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """___________________
- Shape Gen
- Version_0.6
- 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
- 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
- """
- print 'done'
- elapsed = (time.clock() - start)
- print 'Took',elapsed, 'somethings'
Advertisement
Add Comment
Please, Sign In to add comment