Advertisement
gregwa

FCM 156 - Test1.py

Mar 28th, 2020
1,912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import bpy
  2.  
  3. # This function will remove all objects from the scene before the script runs, just to be safe
  4. def clear_scene():
  5.     objs = bpy.data.objects
  6.     for o in objs:
  7.         objs.remove(o, do_unlink=True)
  8.    
  9. clear_scene()
  10. sz = 2
  11. extents = 8.0
  12.  
  13. # Create a single cube and locate it at x=0, y=0 and z=1
  14. bpy.ops.mesh.primitive_cube_add(location=(0,0,1))
  15.  
  16.  
  17. # Add a sun lamp directly above cube on the grid.
  18. bpy.ops.object.light_add(type='SUN', radius=1.0, location=(0.0, 0.0, extents * 0.667))
  19.  
  20. # Add an isometric camera above the grid.
  21. # Rotate 45 degrees on the x-axis, 180 - 45 (135) degrees on the z-axis.
  22.  
  23. bpy.ops.object.camera_add(location=(extents * 1.414, extents * 1.414, extents * 2.121), rotation=(0.785398, 0.0, 2.35619))
  24. bpy.context.object.data.type = 'ORTHO'
  25. bpy.context.object.data.ortho_scale = extents * 7.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement