[SOLVED] How set view from camera (as 0 key)

I need to set the view from camera point of view from python script.

How can I set the default camera to “camera view” as pressing 0 key.


I have tested this, but something is wrong:

>>> bpy.ops.view3d.viewnumpad(type=‘CAMERA’)
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
File “C:\Program Files\Blender Foundation\Blender\2.68\scripts\modules\bpy\ops.py”, line 188, in call
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.view3d.viewnumpad.poll() failed, context is incorrect

I have solved:


[TABLE=“width: 90%, align: center”]


for area in bpy.context.screen.areas:
if area.type == ‘VIEW_3D’:
area.spaces[0].region_3d.view_perspective = ‘CAMERA’