objects.py 502 B

1234567891011121314151617181920212223
  1. # Code licensed under the BSD License.
  2. # http://www.anki3d.org/LICENSE Panagiotis Christopoulos Charitos and contributors
  3. # keep methods in alphabetical order
  4. # blender imports
  5. import bpy
  6. bl_info = {"author": "A. A. Kalugin Jr."}
  7. def get_camera():
  8. """
  9. Gets a camera in the scene.
  10. If one doesn't exist creates one.
  11. """
  12. def getter():
  13. obs = bpy.data.objects
  14. for ob in obs:
  15. if ob.type == 'CAMERA':
  16. return ob
  17. cam = getter()
  18. if cam == None:
  19. bpy.ops.object.camera_add()
  20. return getter()