I have 1000+ cameras and I want to unwrap my mesh UV using project from view from all of them (so creating a UV layer from each camera's project from view) so I can add a UV_PROJECT modifier for each one to texture my mesh. However, Blender's project from view uses the current 3d view as its source. Therefore, I want to align my viewport to a selected camera before performing the project from view using Python.

How can I do this? On Blender's Aligning page, it provides "Align Active Camera to View" but not the inverse I need. I am new to Blender's API and workflow.

  • $\begingroup$ Have you tried bpy.ops.view3d.view_camera()? $\endgroup$
    – Psyonic
    Jun 19, 2021 at 7:48
  • $\begingroup$ It worked! Right now, the background image does not match up with the UV unwrap perfectly (scaling is off) but I am pretty sure it is because I am not projecting with bounds. @Psyonic if you want you can submit an answer so I can confirm it. $\endgroup$ Jun 19, 2021 at 21:45

1 Answer 1


This will iterate through all objects in your .blend If the object is of type CAMERA it gets set as the active scene camera, then the viewport is set to look through it

for ob in bpy.data.objects:
    if ob.type == 'CAMERA':
        bpy.context.scene.camera = ob
        # - YOUR CODE HERE -
  • $\begingroup$ Thank you! The code is helpful. $\endgroup$ Jun 20, 2021 at 6:03

You must log in to answer this question.

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