cwisbg

PythonGrid

Jan 15th, 2019
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. from pymel.core import *
  2. import random as r
  3. def grpr(name):
  4. g = ls(name)
  5. if g:
  6. delete(g)
  7. g = group(n=name,em=1)
  8. return g
  9.  
  10. x = 0
  11. y = 0
  12. z = 0
  13.  
  14. gridSizeX = 4
  15. gridSizeY = 4
  16. gridSizeZ = 2
  17. tmpGrp = grpr("temp_grp")
  18. toGrp = []
  19. i = 0
  20. for z in range(0, gridSizeZ):
  21. for y in range(0, gridSizeY):
  22. for x in range(0, gridSizeX):
  23. #refresh(cw=1)
  24. c = polyCube()[0]
  25. #a = annotate(c, tx=str(x)+str(y)+str(z)+"_"+str(i), p = [x, y, z])
  26. #setAttr(a+".displayArrow", 0)
  27.  
  28. move(c, x, y, z)
  29. #parent(a, c)
  30. scale(c, .005,.005,.005)
  31. toGrp.append(c)
  32. i+=1
  33. parent(toGrp, tmpGrp)
  34.  
  35. randomI = r.randint(0,len(toGrp)-1)
  36. print "Random I : ", randomI, " Group length ", len(toGrp)
  37. randomCube = toGrp[randomI]
  38. #scale(randomCube, .2,.2,.2)
  39. pos = randomCube.getTranslation()
  40. xI = pos.x + gridSizeX * pos.y + gridSizeX * gridSizeY * pos.z
  41. scale(toGrp[int(xI)], .3,.3,.3)
  42. print "Index array number: ", int(xI)," ",pos.y+1
  43.  
  44. if pos.y < gridSizeY-1:
  45. xY = pos.x + gridSizeX * (pos.y+1) + gridSizeX * gridSizeY * pos.z
  46. scale(toGrp[int(xY)], .1,.1,.1)
  47.  
  48. """
  49. i = x + width*y;
  50. i = x + width*y + width*height*z;
  51.  
  52. x = i % width;
  53. y = (i / width)%height;
  54. z = i / (width*height);
  55. """
  56.  
  57.  
  58. select(cl=1)
Advertisement
Add Comment
Please, Sign In to add comment