objects.py 759 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
  2. # All rights reserved.
  3. # Code licensed under the BSD License.
  4. # http://www.anki3d.org/LICENSE
  5. # keep methods in alphabetical order
  6. # blender imports
  7. import bpy
  8. bl_info = {"author": "A. A. Kalugin Jr."}
  9. def get_camera():
  10. """
  11. Gets a camera in the scene.
  12. If one doesn't exist creates one.
  13. """
  14. def getter():
  15. obs = bpy.data.objects
  16. for ob in obs:
  17. if ob.type == 'CAMERA':
  18. return ob
  19. cam = getter()
  20. if cam == None:
  21. bpy.ops.object.camera_add()
  22. return getter()
  23. def get_objects_wuith_no_uvs():
  24. no_uvs = []
  25. obs = bpy.data.objects
  26. for ob in obs:
  27. if ob.type == 'MESH':
  28. _id = (ob.data.uv_layers.active_index)
  29. if _id == -1:
  30. no_uvs.append(ob)
  31. return no_uvs