bpy.data.py 544 B

12345678910111213141516171819202122232425
  1. import bpy
  2. # print all objects
  3. for obj in bpy.data.objects:
  4. print(obj.name)
  5. # print all scene names in a list
  6. print(bpy.data.scenes.keys())
  7. # remove mesh Cube
  8. if "Cube" in bpy.data.meshes:
  9. mesh = bpy.data.meshes["Cube"]
  10. print("removing mesh", mesh)
  11. bpy.data.meshes.remove(mesh)
  12. # write images into a file next to the blend
  13. import os
  14. with open(os.path.splitext(bpy.data.filepath)[0] + ".txt", 'w') as fs:
  15. for image in bpy.data.images:
  16. fs.write("%s %d x %d\n" % (image.filepath, image.size[0], image.size[1]))