Guest User

Cube Blender

a guest
Jun 14th, 2016
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import bpy
  2.  
  3. bpy.data.objects['Cube'].select = True # Select the default Blender Cube
  4. bpy.ops.object.delete() # Delete the selected objects (default blender Cube)
  5.  
  6. #Define vertices, faces, edges
  7. verts = [(0,0,0),(0,5,0),(5,5,0),(5,0,0),(0,0,5),(0,5,5),(5,5,5),(5,0,5)]
  8. faces = [(0,1,2,3), (4,5,6,7), (0,4,5,1), (1,5,6,2), (2,6,7,3), (3,7,4,0)]
  9.  
  10. #Define mesh and object
  11. mesh = bpy.data.meshes.new("Cube")
  12. object = bpy.data.objects.new("Cube", mesh)
  13.  
  14. #Set location and scene of object
  15. object.location = bpy.context.scene.cursor_location
  16. bpy.context.scene.objects.link(object)
  17.  
  18. #Create mesh
  19. mesh.from_pydata(verts,[],faces)
  20. mesh.update(calc_edges=True)
  21.  
  22. bpy.context.scene.objects.active = bpy.context.scene.objects['Cube']
RAW Paste Data