I would like to create several cameras, and store them as follows:

a = bpy.ops.object.camera_add()
b = bpy.ops.object.camera_add()
c = bpy.ops.object.camera_add()

This command allows me to select the camera called "Camera.001"

bpy.data.objects['Camera.001'].select = True

But if my scene already contained several cameras before I created a, b & c, how would I select camera b without knowing its name? This code doesn't work:

bpy.data.objects[b].select = True

Thanks for your help. My python knowledge is minimal.


1 Answer 1


bpy.ops don't return items like that.

Instead, you want to work on the cameras and objects data blocks directly, like so:

camdata = bpy.data.cameras.new(name="Camera A")
a = bpy.data.objects.new(name="Camera A", object_data=camdata)

Then, link it to the currently active scene:


You could then select the camera either, by just doing:

a.select = True

or by doing

bpy.data.objects[a.name].select = True

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .