- If the objects are created, in a second step further manipulations
- What is possible with lists? If in doubt, have a look at Python basics: lists
- Create a script that executes the code from this station.
- Add a new object to the scene and run the script again.
Show all objects
In an new Blender file, in a scene some objects are placed by default. How to get a list of available objects is shown with the following script:
#!bpy """ Name: 'object-list.py' Blender: 2.7x Group: 'Discover' Tooltip: 'Find objects in a scene' """ import bpy def get_list_of_objects(): """ Print list of objects in a scene """ for i in bpy.data.objects: print(i) if __name__ == '__main__': # call the new function get_list_of_objects()
The modul bpy.data contains as structure objects. From this you can get a list of objects of the context, the scene. A for loop is used to print all objects:
<bpy_struct, Object("Camera")> <bpy_struct, Object("Cube")> <bpy_struct, Object("Lamp")>
This is the output on a command line on windows.