How do check the box labeled "Lock Camera to View" using Python?

There is a "lock_camera" property, but I don't know how to navigate to the object that has it to set it.

enter image description here


This code checks the "Lock Camera to View" box:

for area in bpy.context.screen.areas:
   if area.type == 'VIEW_3D':
      for space in area.spaces:
         if space.type == 'VIEW_3D':
            space.lock_camera = True
| improve this answer | |
  • 1
    $\begingroup$ Can also use area.spaces.active to get the space assoc. with the area. $\endgroup$ – batFINGER Apr 27 '18 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.