cwisbg

Shape Gen_version_0.6

Jan 17th, 2012
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.36 KB | None | 0 0
  1. """___________________
  2.    Shape Gen
  3.    Version_0.6
  4.    
  5.    cwisbg
  6.    Brandon Gillespie
  7.    1/16/2012
  8. ______________________      
  9. """
  10. from pymel.core import*
  11. import maya.cmds as mc
  12. import random as r
  13. import time
  14. # Get face locations
  15. def getFace(a):# a = selection, b = face array, c = face place array
  16.     x = 0
  17.     b = [] # array for selecting faces
  18.     c = [] # array for face Locations
  19.     for face in a.f:
  20.         b.append(face) #add face to array
  21.         select(b[x])
  22.         mc.setToolTo('Move')
  23.         c.append(mc.manipMoveContext('Move', q=True, p=True,m=2))
  24.         select(cl=1)
  25.         x += 1
  26.     return b, c  
  27. # For every face in selected object, duplicate selected object at face.
  28. def inctancer(a,b):# a= copy obj, b = location , returns list of duplicated objs
  29.     z = .5
  30.     x = 0
  31.     c = []
  32.     for place in b:
  33.         randoTx = r.randint(1,5)
  34.         randoTy = r.uniform(1,5)
  35.         randoTx = r.randint(1,5)
  36.         randoSx = r.uniform(.2,.4)
  37.         randoRx = r.randint(0,360)
  38.         randoRy = r.randint(0,360)
  39.         randoRz = r.randint(0,360)
  40.         refresh(cv=1)
  41.         cycleCheck(e=0)
  42.         c.append(duplicate(a, n ='{0}_copy_{1}'.format(a,x)))
  43.         move(c[x][0],b[x][0],b[x][1],b[x][2], ls=1,a=1)
  44.         normalConstraint(a,c[x][0]  , w=1, aim = (0,1,0), u = (0,1,0), wut = "scene",n = 'tempNrml')        
  45.         delete('tempNrml')
  46.         move(c[x][0],0,.3,0,os=1,r=1)        
  47.         rotate(c[x][0],0,randoRy,0, os=1, r=1)
  48. #        scale(c[x][0],scaler[0]-z,scaler[1]-z,scaler[2]-z,r=1)
  49.         scale(c[x][0],randoSx,randoSx,randoSx,r=1)
  50.         x += 1
  51. #        z += .01
  52.     return c
  53. #________________________________________________________________________________
  54. start = time.clock()
  55. sl = selected()
  56. x = 1
  57. for i in sl:
  58.     print "on:",x,"of",len(sl)
  59.     faceLocations = []
  60.     level_1_faces = []  
  61.     level_1_faces, faceLocations = getFace(i)
  62.     level_1 = inctancer(i,faceLocations)
  63.     scale(i, .8,.8,.8, r=1)
  64.     rotate(i, 45,45,45, r=1)
  65.     x += 1
  66. """    
  67. #___Duplicate level 2___
  68. x = 0  
  69. for i in level_1:
  70.    print 'on lv2:', x, 'of', len(level_1)
  71.    faceLocations2 = []
  72.    level_2_faces = []  
  73.    level_2_faces, faceLocations2 = getFace(i[0])
  74.    level_2 = inctancer(i,faceLocations2)
  75.    x += 1
  76. """
  77. print 'done'
  78. elapsed = (time.clock() - start)
  79. print 'Took',elapsed, 'somethings'
Advertisement
Add Comment
Please, Sign In to add comment