Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import bpy
  2. from itertools import product
  3. from mathutils import Vector
  4.  
  5. def duplicateObject(scene, name, copyobj):
  6.  
  7. # Create new mesh
  8. mesh = bpy.data.meshes.new(name)
  9.  
  10. # Create new object associated with the mesh
  11. ob_new = bpy.data.objects.new(name, mesh)
  12.  
  13. # Copy data block from the old object into the new object
  14. ob_new.data = copyobj.data.copy()
  15. ob_new.scale = copyobj.scale
  16. ob_new.location = copyobj.location
  17.  
  18. # Link new object to the given scene and select it
  19. scene.objects.link(ob_new)
  20. ob_new.select = True
  21.  
  22. return ob_new
  23.  
  24.  
  25. print(bpy.context.scene.objects.active)
  26.  
  27. orig = bpy.context.scene.objects.active
  28.  
  29. for x in range(0,9):
  30. for y in range(0,9):
  31. for z in range(0,9):
  32. loc = orig.location + Vector([x*0.1,y*0.1,z*0.1])
  33. ob = duplicateObject(bpy.context.scene, "Cube", orig)
  34. print(str(x) + " " + str(y) + " " + str(z))
  35. print(ob)
  36. ob.location = loc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement