diff options
Diffstat (limited to 'doc/python_api/examples/bpy.data.py')
-rw-r--r-- | doc/python_api/examples/bpy.data.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.data.py b/doc/python_api/examples/bpy.data.py new file mode 100644 index 00000000000..7d6bf94532b --- /dev/null +++ b/doc/python_api/examples/bpy.data.py @@ -0,0 +1,27 @@ +import bpy + + +# print all objects +for obj in bpy.data.objects: + print(obj.name) + + +# print all scene names in a list +print(bpy.data.scenes.keys()) + + +# remove mesh Cube +if "Cube" in bpy.data.meshes: + mesh = bpy.data.meshes["Cube"] + print("removing mesh", mesh) + bpy.data.meshes.remove(mesh) + + +# write images into a file next to the blend +import os +file = open(os.path.splitext(bpy.data.filepath)[0] + ".txt", 'w') + +for image in bpy.data.images: + file.write("%s %d x %d\n" % (image.filepath, image.size[0], image.size[1])) + +file.close() |