Skip to main content
deleted 24 characters in body
Source Link
ideasman42
  • 48k
  • 10
  • 144
  • 226

I am using blender command line to render image . But before that I need to select active object as camera, which I am doing by calling bpy.ops.view3d.object_as_camera() .

However I am getting the wicked error Operator bpy.ops.view3d.object_as_camera.poll() failed, context is incorrect

Now when I do the following in Python Console in blender , the active camera is selected bpy.data.objects['Camera001-5'].select = True bpy.context.scene.objects.active = bpy.data.objects['Camera001-5'] bpy.data.scenes[0].camera = bpy.data.objects['Camera001-5'] for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': override = bpy.context.copy() override['area'] = area bpy.ops.view3d.object_as_camera(override) break

bpy.data.objects['Camera001-5'].select = True
bpy.context.scene.objects.active = bpy.data.objects['Camera001-5']
bpy.data.scenes[0].camera = bpy.data.objects['Camera001-5']
for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        override = bpy.context.copy()
        override['area'] = area
        bpy.ops.view3d.object_as_camera(override)
        break

But when I run the script using blender command line, it gives error again. What to do?

I am using blender command line to render image . But before that I need to select active object as camera, which I am doing by calling bpy.ops.view3d.object_as_camera() .

However I am getting the wicked error Operator bpy.ops.view3d.object_as_camera.poll() failed, context is incorrect

Now when I do the following in Python Console in blender , the active camera is selected bpy.data.objects['Camera001-5'].select = True bpy.context.scene.objects.active = bpy.data.objects['Camera001-5'] bpy.data.scenes[0].camera = bpy.data.objects['Camera001-5'] for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': override = bpy.context.copy() override['area'] = area bpy.ops.view3d.object_as_camera(override) break

But when I run the script using blender command line, it gives error again. What to do?

I am using blender command line to render image . But before that I need to select active object as camera, which I am doing by calling bpy.ops.view3d.object_as_camera() .

However I am getting the wicked error Operator bpy.ops.view3d.object_as_camera.poll() failed, context is incorrect

Now when I do the following in Python Console in blender , the active camera is selected

bpy.data.objects['Camera001-5'].select = True
bpy.context.scene.objects.active = bpy.data.objects['Camera001-5']
bpy.data.scenes[0].camera = bpy.data.objects['Camera001-5']
for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        override = bpy.context.copy()
        override['area'] = area
        bpy.ops.view3d.object_as_camera(override)
        break

But when I run the script using blender command line, it gives error again. What to do?

edited title
Link
iamkhush
  • 305
  • 2
  • 12

Incorrect Context error when calling bpy.ops.view3d.object_as_camera()

Source Link
iamkhush
  • 305
  • 2
  • 12

Incorrect Context error when calling

I am using blender command line to render image . But before that I need to select active object as camera, which I am doing by calling bpy.ops.view3d.object_as_camera() .

However I am getting the wicked error Operator bpy.ops.view3d.object_as_camera.poll() failed, context is incorrect

Now when I do the following in Python Console in blender , the active camera is selected bpy.data.objects['Camera001-5'].select = True bpy.context.scene.objects.active = bpy.data.objects['Camera001-5'] bpy.data.scenes[0].camera = bpy.data.objects['Camera001-5'] for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': override = bpy.context.copy() override['area'] = area bpy.ops.view3d.object_as_camera(override) break

But when I run the script using blender command line, it gives error again. What to do?